Hostapd instead of NetworkManager

Hi all,

I’m using the TP-LINK TL-WN725N(EU) V3.0 with chipset RTL8188EUS. I’ve also checked the wifi-connect of balena playground, and in the README it says AP mode isn’t supported and/or isn’t supported by NetworkManager. But, after some googling, it is supported with hostapd or with a forked version of hostapd. So it’s possible to create an access point for this chipset.

So, my question is: is there a way to manage the Wi-Fi USB dongle with hostapd (or a forked version) inside a container instead of NetworkManager, so I can create an access point?

Thanks in advance!

Edit
I’ve found this post: Can't use hostapd with resinOS 2.0. The only thing is, they disable the wireless option of NetworkManager. But I only want to disable 1 device, not all wireless devices. So I’m going to check if there’s a way to do that with NetworkManager.

Hi,
Yes, you can manage Wi-Fi USB dongle with whatever software you want (e.g. networkmanager hostapd). All you will need to not allow NetworkManager to manage this device. You can achieve this with a udev rule like such: ACTION==“add”, SUBSYSTEM==“net”, KERNEL==“eth1”, ENV{NM_UNMANAGED}=“1” (more ways can be found here: https://support.qacafe.com/knowledge-base/how-do-i-prevent-network-manager-from-controlling-an-interface/).
Although we do not see any reason why this particular chipset would not work with NetworkManager in the first place, you are welcomed to try managing this device with hostapd.
Kind regards,
Theodor

Hi @telphan,

Do I need to add this udev rule to config.json or can I also add this udev rule to the container? And if I have to add it to the config.json, how can I do this from inside a container?

I can’t seem to get the Wi-Fi device to work inside a container (Show up in ifconfig). On the HostOS, it is visible.

About the chipset, it works with NetworkManager, but when I want to use it as an access point (mode=ap), I get the response that Access Point mode isn’t supported. So that’s why I want to use hostapd to control it.

Here it is not necessary to put the udevrules in the config.json as you are managing the device from within the container.

Okay, I’ve added the following udev:

SUBSYSTEM=="net", ACTION=="add", ATTRS{idVendor}=="0bda", ATTRS{idProduct}=="8179", ENV{NM_UNMANAGED}="1", NAME="extAP"

My only problem now is that I can’t get the device to show up in ifconfig and when I start the hostapd, I get the errors that there is no such device as extAP.

Is your device being detected? Could you paste the output of lsusb?

Yeah, it’s being detected.

lsusb from container:

Bus 002 Device 002: ID 0424:5734 Standard Microsystems Corp. 
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 8087:0a2a Intel Corp. 
Bus 001 Device 048: ID 0bda:8179 Realtek Semiconductor Corp. RTL8188EUS 802.11n Wireless Network Adapter
Bus 001 Device 008: ID 0424:274c Standard Microsystems Corp. 
Bus 001 Device 006: ID 046d:c52b Logitech, Inc. Unifying Receiver
Bus 001 Device 007: ID 1fd2:6103  
Bus 001 Device 005: ID 0424:2412 Standard Microsystems Corp. 
Bus 001 Device 003: ID 0424:2734 Standard Microsystems Corp. 
Bus 001 Device 002: ID 1491:0020 Futronic Technology Co. Ltd. FS81 Fingerprint Scanner Module
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

lsusb from host OS:

Bus 001 Device 007: ID 1fd2:6103  
Bus 001 Device 002: ID 1491:0020 Futronic Technology Co. Ltd. FS81 Fingerprint Scanner Module
Bus 001 Device 048: ID 0bda:8179 Realtek Semiconductor Corp. RTL8188EUS 802.11n Wireless Network Adapter
Bus 001 Device 008: ID 0424:274c Standard Microsystems Corp. 
Bus 001 Device 004: ID 8087:0a2a Intel Corp. 
Bus 001 Device 005: ID 0424:2412 Standard Microsystems Corp. 
Bus 002 Device 002: ID 0424:5734 Standard Microsystems Corp. 
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 006: ID 046d:c52b Logitech, Inc. Unifying Receiver
Bus 001 Device 003: ID 0424:2734 Standard Microsystems Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Bus 001 Device 048 is the adapter I’m talking about.
Container runs in privileged mode.

Oh, right I see, sorry it took me so long.
Privileged mode does not matter in this case as this has to do with the way docker connects your container’s network, now if you want your container to have full access the host’s network you need to set network_mode: host in your docker-compose file.

Hi @telphan,

Thanks for your answer! With network_mode: host I can find the Wi-Fi USB. But hostapd doesn’t want to start an access point. With some googling, I found that I need to update the drivers. But that’s not really possible within a container, is it?

Maybe it’s time to look around for other AP-enabled Wi-Fi dongles, which is a real bummer…

No, updating network firmwares is not possible altogether without an actual official balenaOS release.

I am sorry to hear, you could not make it work with this dongle.

Hi @bversluijs! Had any luck with the driver of the 0bda:8179 Realtek wifi dongle? Or you just used another dongle?

Thanks!

Hi Matteo,

I’ve not used the realtek wifi dongle in a production environment. I’ve tried to get it working, and you can get it to work using network_mode: host and disable NetworkManager for that device, as described above. I’ve to say, it’s a long time ago, so I don’t remember everything about it.

But in short, from what I can remember, is using the network_mode: host in your container, disable NetworkManager for that device as described above and installing the hostapd fork for the RTL8188eu driver (like lwfinger/rtl8188eu: Repository for stand-alone RTL8188EU driver. (github.com)).


The reason why I didn’t go further with this is because I didn’t think it would work stable enough. I learned a lot about creating an access point and make it manageable (you can read everything here), so maybe with that experience, you can create a much more stable and reliable access point using the Wi-Fi dongle.

I’ve chosen to use the onboard Wi-Fi chip for the Access Point as well as a Wi-Fi client. I’ve created something like the Wi-Fi Connect, but with Node.js and implemented that in my whole application. So when it has Wi-Fi, it’s just a client, and when it can’t connect to Wi-Fi, it’s an AP with captive portal. This removes the need of an extra USB, it just requires a lot of testing and debugging, and it should be suitable for your project of course!

If you need any help, you can always post it here, because you’re not the only one asking about it :slight_smile:.
I’m happy to help debugging any problems you run into by looking at your code. Can’t promise you that I’ll have the solution or if I can try it on my own device, but let me know!

1 Like