Fix Linux DNS Issues Caused by Systemd-Resolved
To be clear, I am not one of those rabid DIE SYSTEMD DIE ASDFJKL sorts of people. There are things I like about it and things I don’t. However one component has been driving me nuts for the past few years: systemd-resolved. First on Arch Linux, then later on Ubuntu. There are bug reports galore, and I feel like I’ve managed to experience pretty much all of them, from intermittently dropped DNS lookups to unresolvable domains to certain libraries not being able to find the Internet at all.
I mean, I know my DNS server IPs (as one does). I don’t need anything fancy. Just give me back my damn access to
/etc/resolv.conf so I can get back to my life, you know?
Anyhoo, if you too are experiencing DNS woes on modern Linux builds, this will show you how to replace systemd-resolved with Unbound. Mind your Es when typing the following; there was apparently disagreement in the developer community over what to name all this shit. Haha. When in doubt, TAB to autocomplete your way to victory.
First things first, if you can’t reach the Internet at all, hop into
/etc/resolv.conf, blow everything away, and add the following:
# Google DNS nameserver 18.104.22.168 nameserver 22.214.171.124
Then install Unbound, which is probably in your distribution’s repo:
# Debian/Ubuntu sudo apt-get install unbound # Arch sudo pacman -S unbound # etc...
Now, shut down and disable systemd-resolved:
sudo systemctl stop systemd-resolved sudo systemctl disable systemd-resolved
That old nanny goat Network Manager needs to be told about Unbound. Open its configuration file, e.g.
/etc/NetworkManager/NetworkManager.conf, and add the following to the
Make sure the Unbound services are enabled:
sudo systemctl enable unbound-resolvconf sudo systemctl enable unbound
Oh, one truly final thing: reboot.
Ubuntu users: if you experience issues with Unbound/NetworkManager not playing nice together, you may need to install the package
dnssec-trigger. This will remove
resolvconf, but should force NetworkManager network settings to be respected. Thanks to reader @Quintin for the tip!
If you’re the tweaking, nudging, prodding sort, you might want to play with the configuration files to get things just right (and/or severely broken). The Archwiki entry provides a solid reference to begin with.