Ubuntu – systemd-networkd daemon does not start the DHCP client

networkingsystemd

I have the appropriate network file with DHCP enabled.

$ cat /etc/systemd/network/20-dhcp.network 
[Match]
Name=enp3*

[Network]
DHCP=ipv4

[DHCP]
UseDomains=true

I have appropriate /etc/resolv.conf as well. I am not using systemd-resolvd daemon (and it may not have anything to do with it, because I did try using it, but did not help anyway).
Any ideas why the DHCP client needs to be run manually to get it working?

Best Answer

Just in case people aren't aware - systemd-networkd now contains its own in-built DHCP client implementation so no external DHCP clients would be started unless they're configured elsewhere.

The configuration is controlled by a number of configuration files as described in the systemd-networkd man page. With Ubuntu18.04 network configuration (/{lib,etc,run}/netplan/*.yaml) is now controlled by netplan which will generate configuration files for systemd-networkd (/{lib,etc,run}/systemd/network/).

Specifically the DHCP client operation is controlled in the systemd.network config file - it can be enabled in the [NETWORK] section of the config file using the DHCP directive (it defaults to "no") and configured the [DHCP] section.