systemd-networkd: how to elegantly switch between creating a wireless access point and connecting to a wifi network

Zbigh1 asked:

I’m working on a headless IoT device that creates its own access point so that the user can access its web UI and do necessary configuration. The system uses networkd but I’m not very attached to it and may change to NetworkManager if it’s better for my use-case.

My question is: how do I elegantly (not by manually replacing config files for networkd and wpa_supplicant) change from exposing the access point to connecting to a configured network? For wpa_supplicant this looks easy – I can control it over dbus from the same process that serves the web UI but networkd doesn’t have a dbus API and I frankly don’t know how to switch from a fixed IP for the wlan interface to DHCP without modifying the network file.

Should I just give up and use NetworkManager?

My answer:


networkd isn’t really designed for handing dynamic network changes of the sort you describe. But this is where NetworkManager excels. I would have started with NetworkManager and not considered networkd for this application at all.


View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.