Skip to content

Multiple network interfaces #8173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Tangerino opened this issue Jan 13, 2022 · 4 comments
Closed

Multiple network interfaces #8173

Tangerino opened this issue Jan 13, 2022 · 4 comments

Comments

@Tangerino
Copy link

In a scenario where a platform supports simultaneously:

  • 4G - Internet access
  • WiFi - Connected to the customer access point for setup/monitoring only (Internet access blocked by proxy)
  • Ethernet - Downstream local devices

Or any combination of above options.

Is there a way to tell the socket what interface to use when opening a socket?

Thank in advance

@dpgeorge
Copy link
Member

Is there a way to tell the socket what interface to use when opening a socket?

I'm not sure. It will depend a lot on the port and how its network subsystem works. Which port do you use?

@Tangerino
Copy link
Author

I'm using ESP32.
An in my use case I might need to use the tree interfaces (eth, wlan and ppp), which will be configurable per installation.
If the use case is not clear, please let me know.
Thank you.

@beyonlo
Copy link

beyonlo commented Jan 14, 2022

Is there a way to tell the socket what interface to use when opening a socket?

This looks more like a networking issue than the MicroPython. In general, will use just the interface that reach that IP that you are trying to open the socket. If you try to open a socket to a IP that is not in the same network/sub-network as configured in the locals interfaces (WiFi/Ethernet), it will try to open the socket using the interface that has the default Gateway, to reach that IP. And, in general, internet access 4G has your default gateway. Those network concepts are used is the mostly Operating System, like as Linux, BSD, Windows, and so on. As MicroPython runs over FeeRTOS (that is a Operating System) I thing it works in the same way - using those network concepts too.

Ps: As far as I know (@dpgeorge can confirm) the MicroPython version 1.17 has ip_forward disabled by default, and the NAT feature not works yet. So I'm considering that your use case is to opening the socket from the MicroPython ESP32 (with 3 interfaces), not from other device via the MicroPython ESP32, because you need ip_forward and NAT enabled if you want to open a socket to the internet via MicroPython ESP32 from other device connected on WiFi or Ethernet, for example.

@Tangerino
Copy link
Author

I got an Olimex EVB board with Ethernet and was able to test.
All works fine when I try to block each of interfaces to reach the web or by removing the cabe, renaming the AP or blocking its IP address.
The RTOS finds a way to use one or another interface and WiFi is the preferable one.
Thank you and I think this can be closed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants