Systemd, NetworkManager, and dhclient

Systemd definitely has its benefits with starting processes in parallel and handling complex dependencies, but NetworkManager seems to thwart that process a bit.  NetworkManager does exactly what it says: it manages the network connection, setting the ip, bringing up the interface, starting dhclient, or any number of other things.  It still has the stigma of being a piece of pretty eye candy around an already good and solid paradigm (the “network” service), but, alas, NetworkManager is here to stay so the quest is to make it place nicely with all of the other services in the systemd sandbox.

NetworkManager brings up the interfaces by kicking off other sub processes, such as dhclient, to complete the initialization process of the network interfaces.  This is done for performance reasons: enabling the system to boot much faster without everything coming to a grinding halt waiting for a DHCP server response.  However, an artifact of this design is that systemd is under the belief that NetworkManager has completed and the processes dependent upon it can now be started.

The catch is that while NetworkManager has indeed completed, dhclient is still finishing up its tasks.  This causes a bit of a race condition for processes dependent upon the interface to have internet connectivity, a race that usually results in the IP address being assigned to the interface after the dependent process has started, failed, and exited.

The solution is to enable an additional NetworkManager service as described on freedesktop.org:

systemctl enable NetworkManager-wait-online.service

Leave a Reply