Ubuntu – How to disable systemd-resolved and resolve DNS with dnsmasq


Ubuntu 16.10+ uses systemd-resolved as DNS resolver.

I prefer the setup 16.04 uses, dnsmasq as the resolver.

How can I do that on 16.10+, especially on 17.04?

Best Answer

dnsmasq packages are still available in 16.10 and 17.04.

  1. Install dnsmasq and dependencies (or at least download their packages) before disabling systemd-resolved:

    sudo apt-get install dnsmasq
  2. Disable systemd-resolved and verify dnsmasq is running:

    sudo systemctl stop systemd-resolved
    sudo systemctl disable systemd-resolved
    systemctl status dnsmasq
  3. Season dnsmasq to taste. After applying your settings, restart dnsmasq:

    sudo systemctl stop dnsmasq
    sudo systemctl start dnsmasq

After step 2 you might be without a working system resolver until step 3 is complete. You may need to restart the networking subsystem (or simply reboot) to get dnsmasq functioning with the default configs. In my testing, adding a known DNS server to /etc/dnsmasq.conf and restarting dnsmasq was enough to get it working in a liveCD environment.