Does systemd-networkd / systemd-resolved add search domains specified in DHCP?
I'm using systemd-networkd and systemd-resolved to manage my network configuration and DNS resolution. I thought it would include search domains specified by the DHCP server, but it doesn't appear to.
# /etc/systemd/network/wlan0.network
[Match]
Name=wlan0
[Network]
DHCP=yes
The DHCP server response includes "Option: (15) Domain Name" (I've checked with wireshark), and I've also tried adding "Option: (119) Domain Search", but nothing I've tried results in a "search" line being added to the resolv.conf file:
# /etc/resolv.conf
# This file is managed by man:systemd-resolved(8). Do not edit.
...
nameserver 192.168.1.1
nameserver fe80::...
I know I can specify Domains=....
in the wlan0.network
or /etc/systemd/resolved.conf
, but I would expect systemd would respect the DHCP options.
I've restarted the network system and confirmed /etc/resolv.conf
is properly symlinked:
$ systemctl daemon-reload && sysetmctl restart systemd-networkd && systemctl restart systemd-resolved
$ ll /etc/resolv.conf
lrwxrwxrwx 1 root root 32 Oct 4 2017 /etc/resolv.conf -> /run/systemd/resolve/resolv.conf
$ pacman -Qi systemd | grep Version
Version : 243.51-1
You should use UseDomains=true
option as suggested in the comment but depending on the version of systemd you were using this would probably not be sufficient. I guess you were hit by the systemd's issue #8174 – systemd-networkd DHCP search domains option which was fixed on July 14th 2019 and released in version 243 of systemd on September 3rd 2019.
The issue was described as follows:
I expected that by enabling [DHCP]: UseDomains=true in network configuration, the DHCP client would use DHCP provided search domains. The client only uses DHCP provided search domains if the server specifies this option as "forced"
By the way, I highly recommend asking Linux specific questions at https://unix.stackexchange.com