Create a Wi-Fi access point with a DHCP server


I’m essentially trying to re-create the network setup flow of the wifi-connect snap on Ubuntu Core, but in Node.js. In other words:

  1. Start a Wi-Fi access point on my IoT device on boot
  2. Allow clients to connect to that access point
  3. Host a web interface which allows clients to get a list of nearby Wi-Fi networks
  4. Allow a client to connect the IoT device to one of those networks

I’ve got steps 1, 3 and 4 working, but I’m a bit stuck on step 2 because clients which connect to the Wi-Fi access point don’t get assigned an IP address and so can’t access the web server hosted on the IoT device. I assume this is because I need to enable a DHCP server on the IoT device at step 2 and then disable it again at step 4?

The wifi-connect snap appears to use dnsmasq for this, but I don’t really understand how it works.

My work-in-progress PR which creates a Wi-Fi access point is here.

Can anyone point me in the right direction as to how I configure a DHCP server and dynamically turn it on and off? Can this be done using NetworkManager via D-Bus, or do I need to use some other approach? Crucially, is this possible without root? My snap gets switched over to the snap_daemon user shortly after startup.

There’s some brief documentation which says the NetworkManager snap can be used to create a Wi-Fi access point, but it doesn’t mention DHCP.

I know there have been several previous threads related to this topic but I couldn’t quite find the answer I was looking for.



network-manager can do all this automatically … have a look at


this simply packages up the WifiAP demo script that NM ships in the examples dir, it is plain python, you should be able to grab that and deduct the necessary d-bus calls used to configure NM, then it should be easily possible to translate this into nodejs code …

Thanks for the reply.

This looks very similar to what I’m already doing by following the example in the wifi-connect snap.

The main difference seems to be that it first configures a connection and then activates it, rather than doing both in one step using org.freedesktop.NetworkManager.AddAndActivateConnection.

If this works without having to manually configure DHCP via dnsmasq etc. then maybe I’ve just got some settings wrong. I’ve found the NetworkManager documentation very hard to understand so I’m probably just missing something.

I’ll keep trying…

1 Like