6

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?

9

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.

1
  • 1
    Welcome , could you explain the built-in dhcp in systemd-network , please.
    – GAD3R
    Nov 1 '18 at 19:08
4

From reading man systemd.network, it sounds like the .network files in /etc/systemd/network are controlled by systemd-networkd. If the files aren't being read, it could be that you aren't using this part of systemd.

For example, on a Ubuntu 16.04 desktop, I can see that systemd-networkd is not in use:

 systemctl status systemd-networkd

● systemd-networkd.service - Network Service Loaded: loaded (/lib/systemd/system/systemd-networkd.service; disabled; vendor preset: enabled) Active: inactive (dead) Docs: man:systemd-networkd.service(8)

Instead, the NetworkManager service is running. So, a DHCP client would be configured through NetworkManager in that case, or NetworkManager needs to be stopped and disabled, and systemd-networkd needs to be started and enabled.

2
  • 2
    Yes, systemd-netword is enabled and running. I had uninstalled NetworkManager before migrating to systemd-networkd
    – Salil
    Mar 11 '17 at 20:30
  • I've now added some more info on configuration.
    – Pierz
    Nov 2 '18 at 14:27
3

It turned out that I had two network files. I followed arch linux systemd-networkd documentation (https://wiki.archlinux.org/index.php/systemd-networkd#Wireless_adapter), and created one network file:

/etc/systemd/network/25-wireless.network
[Match]
Name=wlp2s0

[Network]
DHCP=ipv4

And it is working.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.