The systemd-resolved service is failing to update resolv.conf because it’s detecting too many nameservers, which it interprets as a sign of manual configuration or a conflict.
Here are the common causes and their fixes:
Cause 1: Manual resolv.conf Edits
You or another process manually edited /etc/resolv.conf, adding nameservers that systemd-resolved doesn’t recognize as being managed by it. systemd-resolved expects to be the sole manager of /etc/resolv.conf.
-
Diagnosis:
cat /etc/resolv.confLook for lines like
nameserver 1.1.1.1ornameserver 8.8.8.8that were not added bysystemd-resolved. Also, check if/etc/resolv.confis a regular file instead of a symbolic link to/run/systemd/resolve/stub-resolv.confor/run/systemd/resolve/resolv.conf.ls -l /etc/resolv.conf -
Fix: Remove the manual entries from
/etc/resolv.confand ensure it’s a symlink managed bysystemd-resolved. If it’s a regular file, you’ll need to remove it and recreate the symlink.sudo rm /etc/resolv.conf sudo ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf sudo systemctl restart systemd-resolvedThis works because
systemd-resolvedwill then take over management of the symlink, ensuring its own dynamic entries are used and that no conflicting manual entries exist.
Cause 2: NetworkManager Interference
NetworkManager, another common network configuration tool, might be configured to manage /etc/resolv.conf directly, leading to conflicts with systemd-resolved.
-
Diagnosis: Check the NetworkManager configuration for
dnssettings.grep 'dns=' /etc/NetworkManager/NetworkManager.confAlso, check if NetworkManager is actively managing
/etc/resolv.conf.ls -l /etc/resolv.confIf
/etc/resolv.confis a symlink to/run/systemd/resolve/resolv.conf(notstub-resolv.conf) and NetworkManager is configured to manage DNS, this is a likely conflict. -
Fix: Configure NetworkManager to let
systemd-resolvedhandle DNS. Edit/etc/NetworkManager/NetworkManager.conf:[main] plugins=ifupdown,keyfile # Uncomment the following line if it exists and is set to 'yes' # dns=defaultChange it to:
[main] plugins=ifupdown,keyfile dns=noneThen, restart NetworkManager and
systemd-resolved:sudo systemctl restart NetworkManager sudo systemctl restart systemd-resolvedSetting
dns=nonein NetworkManager tells it not to touch/etc/resolv.conf, allowingsystemd-resolvedto manage it exclusively via itsstub-resolv.conforresolv.confsymlink.
Cause 3: DHCP Client Overrides
Your DHCP client (e.g., dhclient, dhcpcd) might be configured to write nameservers directly into /etc/resolv.conf after receiving them from the DHCP server, ignoring systemd-resolved.
-
Diagnosis: Examine the configuration of your DHCP client. For
dhclient:grep 'prepend domain-name-servers' /etc/dhcp/dhclient.confIf you find lines that instruct
dhclientto modifyresolv.conf, that’s the issue. -
Fix: Configure the DHCP client to not update
/etc/resolv.conf. Fordhclient, edit/etc/dhcp/dhclient.confand comment out or remove lines that instruct it to modifyresolv.conf. Specifically, look for and remove or comment out:prepend domain-name-servers ...;And ensure it’s not set to update
resolv.confby default. Theresolvconf=NOoption is often used to prevent this.sudo systemctl restart networking # or your network service sudo systemctl restart systemd-resolvedBy preventing the DHCP client from directly writing to
resolv.conf, you allowsystemd-resolvedto manage the file, integrating the DHCP-provided nameservers correctly.
Cause 4: Static IP Configuration with Manual DNS
If you’ve configured a static IP address on an interface, you might have also manually specified DNS servers in the interface configuration file, which can conflict with systemd-resolved.
-
Diagnosis: Check your network interface configuration files. For example, on Debian/Ubuntu systems:
cat /etc/network/interfacesOr for Netplan:
cat /etc/netplan/*.yamlLook for
dns-nameserversor similar directives within interface stanzas. -
Fix: Remove the manual
dns-nameserversentries from your static interface configuration and rely onsystemd-resolvedto provide DNS. For Netplan, modify the YAML file:network: version: 2 ethernets: eth0: dhcp4: no addresses: [192.168.1.100/24] # Remove or comment out the 'nameservers' section: # nameservers: # addresses: [8.8.8.8, 8.8.4.4] routes: - to: default via: 192.168.1.1Then apply the Netplan configuration:
sudo netplan apply sudo systemctl restart systemd-resolvedBy centralizing DNS management with
systemd-resolvedand removing explicit DNS server definitions from static interface configurations, you avoid duplicate or conflicting entries.
Cause 5: Multiple DNS Resolvers Configured in systemd-resolved
While less common, it’s possible that systemd-resolved itself is configured to use multiple upstream DNS servers in a way that triggers this warning, perhaps through complex resolved.conf settings or by picking up too many from different sources.
-
Diagnosis: Check
systemd-resolved’s own configuration.cat /etc/systemd/resolved.confLook for
DNS=andFallbackDNS=entries. Also, check the status ofsystemd-resolvedfor any clues.sudo systemctl status systemd-resolved -
Fix: Simplify
systemd-resolved’s configuration. Ensure thatDNS=andFallbackDNS=in/etc/systemd/resolved.confare either commented out (to let DHCP/network management provide them) or contain a clean, minimal set of addresses. For example, to rely solely on DHCP/network manager:[Resolve] #DNS= #FallbackDNS=Or, to set specific servers:
[Resolve] DNS=1.1.1.1 8.8.8.8 FallbackDNS=9.9.9.9Then restart the service:
sudo systemctl restart systemd-resolvedThis ensures that
systemd-resolvedisn’t being fed an excessive number of servers by its own configuration or by misinterpreting network-provided settings.
Cause 6: Systemd-resolved is not running properly or is in a bad state
Sometimes, the service might be in a transitional or error state, leading it to misinterpret the DNS configuration.
-
Diagnosis:
sudo systemctl status systemd-resolved journalctl -u systemd-resolved --since "1 hour ago"Look for any errors or unusual states.
-
Fix: A simple restart might clear a transient issue. If that doesn’t work, try resetting the configuration.
sudo systemctl stop systemd-resolved sudo rm /etc/resolv.conf # If it's a symlink, this is fine. If it's a file, be cautious. sudo rm /run/systemd/resolve/* # Be careful with this if other services depend on these files directly. sudo systemctl start systemd-resolved sudo ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf # Recreate the symlinkThis forces
systemd-resolvedto re-initialize its state and rebuild itsresolv.conffrom scratch.
After applying the correct fix for your situation, the next warning you might encounter is related to DNS resolution itself, such as "DNS resolution failed" if the configured nameservers are unreachable or misconfigured.