How can I disable systemd-resolved in Ubuntu 17.04?

Disabling it with systemctl disable didn't work, the service seems to be restarted (by Networkmanager?)

  • 5
    systemd-resolved isn't just big, it also breaks the way dns resolution works by not always attempting to resolve in the order dns servers are specified in the client config. When a server doesn't resolve a domain, the next in the list is moved to the top (Poettering calls that 'memory'). See this thread for the details. – LifeBoy Jun 26 '17 at 6:57
up vote 77 down vote accepted

Caution! Be aware that disabling systemd-resolvd might break name resolution in VPN for some users. See this bug on launchpad (Thanks, Vincent).

Disable the systemd-resolved service and stop it:

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

Put the following line in the [main] section of your /etc/NetworkManager/NetworkManager.conf:

dns=default

Delete the symlink /etc/resolv.conf

rm /etc/resolv.conf

Restart network-manager

sudo service network-manager restart
  • 4
    this does not seem to work on Ubuntu 17.04. Alsi, the config file is /etc/NetworkManager/NetworkManager.conf . Name resolving breaks when I do the above. systemd-resolved sucks big time, now the VPN DNS resolving doesn't work properly at all for me. Bug progress can be found here: bugs.launchpad.net/ubuntu/+source/systemd/+bug/1624317 – Vincent Gerris Apr 28 '17 at 10:13
  • 4
    I think you should add to the above answer that "apt-get install dnsmasq" should be done once systemd-resolved has been disabled. – LifeBoy Jun 26 '17 at 6:59
  • 2
    Just tested on 17.04 and works out-of-the-box (with dnsmasq part of course) – tribbloid Jul 11 '17 at 0:35
  • 3
    This solution worked for me as a workaround for DNS resolution problem on Ubuntu 17.10. – vahid-dan Nov 1 '17 at 2:35
  • 5
    For Ubuntu 18.04, all that is needed is to run the commands sudo systemctl disable systemd-resolved.service and sudo service systemd-resolved stop. That worked for me. – Daniel Eagle May 5 at 14:53

I've recently upgraded to (k)Ubuntu 17.04 and I also stumbled upon the change to systemd.

My setup is fairly typical I think, in that I have a DNS provider in my broadband HUB and this is my primary source of information for all the devices on my network (of which I have a few).

There is some beauty in systemd, it's not all bad but what is really bad is the documentation, the lack of communication from the Ubuntu team and the gung-ho "let's just change it despite it breaks for everyone" mentality.

The solution for me after tearing some hair out was to edit /etc/systemd/resolved.conf:

[Resolve]
DNS=192.168.1.254   # <-- change to your router address
#FallbackDNS=8.8.8.8 8.8.4.4 2001:4860:4860::8888 2001:4860:4860::8844
Domains=lan         # <-- change to your localdomain name (maybe .local)
#LLMNR=yes  <-- I dabbled with this for a while but it doesn't matter
#DNSSEC=no
#Cache=yes
#DNSStubListener=udp

After not understanding why this wouldn't work I figured out that what was also needed was to switch /etc/resolv.conf to the one provided by systemd. This isn't the case in an out-of-a-box install (for reasons unknown to me).

sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf

The local DNS server is then not used and all DNS requests are sent to my HUB.

I think this is a much better solution than cutting out and putting in some other solution since systemd-resolv is now the default onwards.

A related problem btw is that the /etc/nsswitch.conf is neutered.

It should read:

hosts: files mdns4_minimal dns [NOTFOUND=return] resolve [!UNAVAIL=return] dns

This is a confusing configuration since [NOTFOUND=return] means processing ends there. The entries after it will never be used.

  • 1
    And then I have to change the router address in the config everytime I connect to a new WIFI? U serious? -1 – Bastian Voigt Jul 24 '17 at 7:25
  • I didn't realise you were roaming with it. If you are, then leave the configuration items commented out. You should then get a /etc/resolv.conf that says: nameserver 8.8.8.8 nameserver 8.8.4.4 – user2427436 Jul 25 '17 at 18:58

If you are having leaks issues with your VPN and can't figure out how to set up systemd (like me) you can remove it in the way described in the first answer but don't add the dns=default line because it will activate the nameserver 127.0.0.1. To set the router as dns, create the file "tail" in your /etc/resolvconf/resolv.conf.d/ folder adding the line nameserser 192.168.1.1

do ln -sf /var/run/resolved/resovl.conf /etc/resolv.confif you had messed up with this file.

  • 1
    Really? For me it works exactly as described in my answer. Definitly not using nameserver 127.0.0.1. I also think it is not very handy to hardcode the IP of your nameserver in a config file. At least I switch wifi networks quite often and each wifi has a different nameserver – Bastian Voigt Sep 6 '17 at 14:42
  • yes 'default' enables 127.0.0.1 as dns – Yvain Sep 8 '17 at 17:33

protected by Community Dec 28 '17 at 11:31

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.