Fixing /etc/resolv.conf on Ubuntu 22.04 from command line

Krishnendu Paul

Nov 17, 2023 1 min read

Why does /etc/resolv.conf keep changing after reboot ?

Issue is systemd-resolved - on latest Ubuntu system, it is what handling resolv.conf settings. And /etc/resolv.conf actually is a symlink to /run/systemd/resolve/resolv.conf managed by systemd-resolved

Yes, I know - it is painful. Once you are rebooting server - /etc/resolv.conf resetting to the previous configuration, most probably like following


To fix, 1st, check /etc/systemd/resolved.conf. Enable DNS and FallbackDNS



Restart system resolved: service systemd-resolved restart

Still not resolved ? Ok - try following and 90% chances that problem will be fixed.

rm -f /etc/resolv.conf
ln -sv /run/systemd/resolve/resolv.conf /etc/resolv.conf

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.