The issue lies with systemd-resolved. On the latest Ubuntu systems, systemd-resolved is responsible for managing /etc/resolv.conf
. By default, /etc/resolv.conf
is a symbolic link to /run/systemd/resolve/resolv.conf
, which is dynamically managed by systemd-resolved.
{tocify} $title={ Table of Contents }
Unfortunately, this means that any custom changes you make to /etc/resolv.conf
will be overwritten upon reboot. After rebooting, the file typically resets to a default configuration such as:
nameserver 127.0.0.53
How to Fix It
To resolve this issue, follow these steps:
Update /etc/systemd/resolved.conf
Edit the /etc/systemd/resolved.conf file and set the desired DNS servers under the DNS and Fallback DNS options. For example:DNS=1.1.1.1 8.8.8.8
FallbackDNS=8.8.4.4
#Domains=
#DNSSEC=no
#DNSOverTLS=no
#MulticastDNS=no
#LLMNR=no
#Cache=no-negative
#CacheFromLocalhost=no
#DNSStubListener=yes
#DNSStubListenerExtra=
#ReadEtcHosts=yes
#ResolveUnicastSingleLabel=no
Restart systemd-resolved
Apply the changes by restarting the service:
sudo systemctl restart systemd-resolved
Still Not Working?
If the problem persists, try the following steps to recreate the symbolic link:sudo rm -f /etc/resolv.conf
sudo ln -sv /run/systemd/resolve/resolv.conf /etc/resolv.conf
In most cases, this should resolve the issue and prevent /etc/resolv.conf
from reverting to its default state.