• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[SOLVED] Wifi in a Container
#1
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?
  Reply
#2
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.

You never fail until you stop trying.“, Albert Einstein (1879 - 1955)

  Reply
#3
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
  Reply
#4
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





You never fail until you stop trying.“, Albert Einstein (1879 - 1955)

  Reply
#5
Hello Armin

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

  Reply
#6
Thank you for your feedback
You never fail until you stop trying.“, Albert Einstein (1879 - 1955)

  Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  Exporting and importing container images Armin@netPI 0 12 August-23rd-2019, 10:39 AM
Last Post: Armin@netPI
  Ready-to-deploy: full featured Node-RED container Armin@netPI 5 66 July-25th-2019, 06:16 AM
Last Post: Armin@netPI
  New Container example "OPC UA server" Armin@netPI 0 15 April-12th-2019, 11:51 AM
Last Post: Armin@netPI
  Official Node-RED container Armin@netPI 0 17 April-5th-2019, 10:39 AM
Last Post: Armin@netPI
  Multi-stage builds for slim container images Armin@netPI 0 10 February-7th-2019, 04:14 PM
Last Post: Armin@netPI
Information [INFO] Setting the correct timezone in a container Armin@netPI 0 10 February-3rd-2019, 08:23 AM
Last Post: Armin@netPI
  [SOLVED] Unique identifier in container mmolder 1 25 January-23rd-2019, 03:06 PM
Last Post: Armin@netPI
  [SOLVED] activate LED1/2 with Node-RED + fieldbus nodes container Christian_Rau 5 77 January-11th-2019, 08:06 AM
Last Post: Armin@netPI
  [SOLVED] Portainer does not start container Steres 3 201 October-16th-2018, 06:54 PM
Last Post: Armin@netPI
  [SOLVED] install ssh service to running container paubau 2 135 October-12th-2018, 01:03 PM
Last Post: paubau

Forum Jump:


Users browsing this thread: 1 Guest(s)