How do I disable systemd-resolved and replace with something sane on Ubuntu 18?

I've decided systemd-resolved is irretrievably broken garbage and I'd like to replace. I've got my own local DNS server at 192.168.1.2 I'd like. I'd also like to connect to a VPN with NetExtender that gives me a DNS server for a .local domain. I would like these two things to work together, what can I do?


Solution 1:

The answer by Gannet is incorrect. If you want to use plain ifupdown like in earlier releases, without netplan or NetworkManager (e.g. on a server), with dhcp, you need to do this:

systemctl disable systemd-resolved.service
systemctl stop systemd-resolved.service

# check if resolv.conf is pointing to resolvconf
ls -la /etc/resolv.conf
# lrwxrwxrwx 1 root root 27 May  7 16:15 /etc/resolv.conf -> /run/resolvconf/resolv.conf
# if not, delete /etc/resolv.conf and symlink it like this: 
rm /etc/resolv.conf
ln -s /run/resolvconf/resolv.conf /etc/resolv.conf

# this will remove the resolved stub resolver entry from resolv.conf
resolvconf -d systemd-resolved

# fix dhclient scripts
chmod -x /etc/dhcp/dhclient-enter-hooks.d/resolved
chmod +x /etc/dhcp/dhclient-enter-hooks.d/resolvconf

# on my machine just chmod -x wasn't enough, I had to move the resolved script somewhere else
mv /etc/dhcp/dhclient-enter-hooks.d/resolved ~

# ifdown/ifup your interface to regenerate resolv.conf (or systemctl restart ifup@eth0)
ifdown eth0; ifup eth0

# check /etc/resolv.conf has the right settings

Solution 2:

You can always disable your systemd-resolved by

systemctl disable systemd-resolved.service

command. And run:

sudo rm /etc/resolv.conf && sudo ln -s /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf

to use /etc/resolv.conf config as it was earlier in previous ubuntu versions.