Hilscher Community Forum
[SOLVED] Wifi in a Container - Printable Version

+- Hilscher Community Forum (https://forum.hilscher.com)
+-- Forum: netPI 3 - Docker featuring Industrial Raspberry Pi 3 platform (https://forum.hilscher.com/forum-1.html)
+--- Forum: Software (https://forum.hilscher.com/forum-5.html)
+--- Thread: [SOLVED] Wifi in a Container (/thread-199.html)



[SOLVED] Wifi in a Container - iotuser - March-22nd-2018

How can I use Wifi (in client mode) from within a container?

I'm using hilschernetpi/netpi-nodered-fieldbus:latest with Network=host and would like to connect to the cloud using Wifi instead of eth0.
What do I need to do to enable the Wifi within the container?


Answer - Armin@netPI - March-22nd-2018

Hello Iotuser,

this is very easy. If you use the option "network=host" then docker starts the container using the same TCP/IP stacks as the Linux Host system. In this case it is not a matter of the physical interfaces eth0 and wifi any more, but just a matter of the ip addresses that you have configured.

So make a simple test:
If you configure the eth0 IP address of netPI to 192.168.30.1 for example then you can reach the node-red under 192.168.30.1:1880.
If you now configure the wifi address of netPI to 192.168.40.1 for example (in access point mode) and you connect your mobile phone to this wifi network getting then you can reach node-red under 192.168.40.1:1880 also.




Answer - iotuser - March-23rd-2018

Hello Armin
Thanks for the fast response!

Accessing the node-red UI over Wifi works fine.
What I like to do is to connect my node-red to an Azure IoT Hub using the Wifi connection which fails with a "EHOSTUNREACH" error (using https 443 as outgoing port) .
The same scenario using eth0 worked fine. Any additional configuration required for this?

Best Regards


Answer - Armin@netPI - March-23rd-2018

Hello iotuser,

just to understand it right. You have a Wifi network active and a router that is providing an IP address to netPI over Wifi. Is that correct? In this case netPI operates as a "Wifi Client"

Now you have two networks in netPI active. eth0 and wlan0. In both configuration settings you will have next to the ip address, also a subnet mask and also a gateway active, right?

Now if the node-red container wants to "send something" it has two interfaces eth0 and wlan0 where he is able to send it, but now he does not know which interface shall be used for sending out data. Linux in this case does it in a very practical way: it uses the first interface that has a gateway address and sends data across this one found first. In your case it will be eth0.

So in order to get data be sent across wlan0, you have to delete the gateway address of interface eth0. Then linux will use the gateway of wlan0 address instead and will send your data over your Wifi router








Answer - iotuser - March-23rd-2018

Hello Armin

Deleting the Gateway address solved the issue.
Thanks a lot! I knew it must be something stupid...




Answer - Armin@netPI - March-23rd-2018

Thank you for your feedback