I am in the process of upgrading my production server from Ubuntu 14.04 to 18.04 and noticed that there is something called systemd-resolved
in 18.04 which run a local DNS cache of sorts. [1]
Why is this required? What is wrong with simply putting nameserver 1.1.1.1
or nameserver 8.8.8.8
in /etc/resolv.conf
and calling it a day? Is it safe to disable systemd-resolved
and revert to the simpler configuration?
[1] I noticed only because it is randomly crashing and causing all hostname lookups to fail, effectively crippling my app - https://askubuntu.com/questions/1117842/systemd-resolved-crashing-with-failed-to-set-up-mount-namespacing-invalid-argu
The logic of it is that Ubuntu has a built in DNS cache, which it checks first when trying to resolve anything. In this version, by default, NetworkManager is not updating /etc/resolv.conf instead it’s calling application called resolvconf.
This approach:
May not make it through a reboot.
To get rid of the problem, we can try harder:
add the following lines to the [main] section of NetworkManager.conf:
Then restart net manager:
That should make the system use the classic resolv.conf .
An alternate dirty trick is to makes the service un-startable until you "unmask" it:
The unsafe part of this may be that disabling it might break name resolution in some VPN scenarios. So if you want to use VPNs, make sure to do proper testing of their functionality after getting rid of systemd-resolved.