Making WiFi hotspot - whilst still having ethernet/cellular connected on Fin

wifi

#1

I’m using a Fin with balenaOS 2.26.0+rev1 and I want to modify the WifiConnect app to make my own permanent hotspot, whilst still having the Fin connected to Balena via a cellular modem or the ethernet. I have some questions;

  • dnsmasq can’t run in the container as it seems to be running on the host OS. How does the WifiConnect app stop dnsmasq before starting it’s own instance?
  • If I stop the main dnsmasq running on the host OS somehow, will I prevent the device from being connected to BalenaCloud? I want the wifi hotspot and the host OS connection to be maintained simultaneously.

Any input greatly appreciated. I can see the custom hotspot, but I am not given an IP address as dnsmasq won’t run due to it already running in the host OS. I’m using the Python example given on the Balena support page mixed with the hotspot settings from here:

and the python from

https://www.balena.io/docs/reference/OS/network/2.x/#changing-the-network-at-runtime

Given the hotspot works it seems all I need is to figure the DHCP part out!


#4

Hi @clong!

First, I have just tested running wifi-connect while connected to ethernet, and I can confirm it works as expected (Raspberry Pi 3, balenaOS 2.27.0+rev1, supervisor version 8.3.5).

wifi-connect launches a second instance of dnsmasq by binding to a different address (the hostOS binds to 127.0.0.2, wifi-connect uses 192.168.42.1). This second address is then used for the ad-hoc wifi network that’s created, allowing a persistent wired connection and a Wifi Connect access point.

To your second question, I would advise against stopping any daemons on the hostOS. This process resolves internal balena network addresses, and will cause unexpected behavior. I have just tested locally, and after pushing an updated wifi-connect, the supervisor is unable to pull the update.

Nov 28 23:26:07 6c1d47f resin-supervisor[1065]: [2018-11-28T23:26:07.531Z] Failed to get target state for device: Error: getaddrinfo ENOTFOUND api.balena-cloud.com api.balena-cloud.com:443

I hope this helps! Please let us know if you have any other questions.


#6

Thanks.

I can confirm it works as you suggest. For anybody else, I made the simply mistake of trying to run dnsmasq manually even thought the apt-get install dnsmasq has already installed the system service. It had nothing to do with the host OS.

As a result, all that was needed was to copy my own config to /etc/dnsmasq.conf. That way, I don’t have to configure or manage dnsmasq at all. I’m not sure how wifi-connect does this, but I don’t need to know I guess.


#7

Hi @clong, just to clarify this a bit further, if you happen to face a similar situation where you would like to run an application which is also installed as a service, you can do systemctl mask dnsmasq.service which will disable it running as a service. (this is assuming INITSYSTEM is enabled for the container)

So there are few ways to use dnsmasq from a container:

You may spawn it as a child process from an application - this is how wifi-connect uses it. When wifi-connect is closed, it closes dnsmasq.

A second way would be to just use dnsmasq as a single process in a container - that is as part of a multi-container application.

And the third way is by using it as a service (with INITSYSTEM enabled in the Dockerfile).