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?)

  • 26
    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
    Commented Jun 26, 2017 at 6:57
  • 10
    it also bypasses iptables rules, which is a terrible idea.
    – Spongman
    Commented Oct 23, 2018 at 3:37
  • 1
    It occurs to me that the _gateway name is provided by systemd-resolved... My entire networking stack relies on that was braking my system every time I tried to host a full featured DNS. :facepalm:
    – Ray Foss
    Commented Feb 6, 2021 at 18:23
  • 2
    @HaroldFischer i don't have a reference. try it yourself: add some iptables rules for redirecting DNS traffic (in my case i was doing this on a per-user basis), then enable systemd-resolved and see how it completely ignores the iptables rules. at least, it did ~Oct/2018. haven't tried it since then.
    – Spongman
    Commented Mar 22, 2021 at 18:49
  • 2
    @HaroldFischer no offense taken. i had a similar situation, i was using iptables to conditionally redirect outgoing dns traffic to different servers based on the local group-id. i don't remember the exact iptables incantations (i think i was using shorewall to do it). anyway... i updated my OS and systemd-resolved got installed, and the iptables rules stopped working - all DNS traffic was sent directly to the configured server bypassing the iptables rules.
    – Spongman
    Commented Mar 30, 2021 at 23:15

5 Answers 5


This method works on the Ubuntu releases 17.04 (Zesty), 17.10 (Artful), 18.04 (Bionic), 18.10 (Cosmic), 19.04 (Disco) and 20.04 (Focal):

Disable and stop the systemd-resolved service:

sudo systemctl disable systemd-resolved
sudo systemctl stop systemd-resolved

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


Delete the symlink /etc/resolv.conf

rm /etc/resolv.conf

Restart NetworkManager

sudo systemctl restart NetworkManager

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

  • 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 Commented Apr 28, 2017 at 10:13
  • 5
    I think you should add to the above answer that "apt-get install dnsmasq" should be done once systemd-resolved has been disabled.
    – LifeBoy
    Commented Jun 26, 2017 at 6:59
  • 8
    @LifeBoy I don't use dnsmasq. I just don't use any local nameserver, do not see the value of that. Commented Oct 9, 2017 at 9:17
  • 12
    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. Commented May 5, 2018 at 14:53
  • 35
    Thank you. SystemD is ruining Linux, making it from something reliable and understandable to something that works via magic. Commented Aug 14, 2018 at 8:24

If you are using Ubuntu 18.04 Server (or Ubuntu 20.04 Server), none of these answers apply. The one by user2427436 comes closest.

The issue is that systemd-resolved is/runs a stub resolver, and I just need to completely disable that (per the question). I need to do this because Zimbra 8.8.15 (FOSS) comes with its own integrated resolver (unbound).

In my situation I am starting from a stock (naive) install of server 18.04, with minimal options on bare metal (well, actually a VM).

so here's the recipe:

   vi /etc/systemd/resolved.conf
     edit line #DNSStubListener=yes
         to be DNSStubListener=no
   systemctl stop systemd-resolved
   systemctl status systemd-resolved
   rm /etc/resolv.conf
   reboot to test...

This is what /etc/systemd/resolved.conf looks like now:

# See resolved.conf(5) for details

that's all it took.

Feel free to install any other resolver you want after this.

  • 3
    Finally a good answer... I just need Debian Buster/Ubuntu 20.04 LTS to play nice with a real DNSServer... there is no easy way to update systemd-resolved to a version that allows exposing it's forwarding, DNSoverTLS and caching to the LAN. It's becoming a serious issue where 10 year old bad answers in SO still take precedence over correct recent answers
    – Ray Foss
    Commented Feb 6, 2021 at 18:18
  • 1
    Could not agree more about systemd. StackExchange FTW! Just came to amend the answer -- it also works with server 20.04 (same initial conditions).
    – BISI
    Commented May 18, 2021 at 21:17
  • "feel free to install any other resolver you want after this" doing what you suggested would disable that system-resolved which is not available in other Linux distros like centos, my question is that does for instance centos have another resolver by default? I want to know whether disabling system-resolved in Ubuntu makes it like centos or do I need to do more than that? Commented Mar 11, 2023 at 7:29
  • And also does this work Ubuntu 22? Why did you say server version, doesn't this work with a non server version too? Commented Mar 11, 2023 at 7:31
  • as always, the questions are easier than the answers :-/ No, removing systemd-resolved does nothing to make ubuntu into redhat. Your centos question would be better asked on a centos forum. As for whether the same approach works with the desktop version - try it yourself! As I said in the first line, the previous answers did not work for the server versions of ubuntu. I have not needed to upgrade anyone to server 22.04, nor do a fresh install, so I can't comment beyond wagering a beer that the recipe would work with ubuntu server 22.04. Do let us know about the desktop experiment.
    – BISI
    Commented Mar 13, 2023 at 6:26

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:

DNS=   # <-- change to your router address
#FallbackDNS= 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

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 Commented Jul 24, 2017 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 nameserver Commented Jul 25, 2017 at 18:58
  • 2
    I don't think it's necessary to edit resolved.conf if you set up netplan correctly. i.e., netplan writes the correct values to the symlinked file... PS SYSTEMD SUCKS!
    – user70382
    Commented Jan 7, 2019 at 11:56
  • 2
    I prefer taking all the resolver-breakers out. there's usually not more than 2-3 legit resolver updates in 5 years of lifetime of 10000s of servers but guys keep optimizing for a laptop. doesn't matter to them if companies lose millions due to prolonged outages caused by this stuff, and the impact on safety-critical systems is just waved away by "those people will test/optimize it anyway". yup. by removing it. so noone dies. Commented Apr 11, 2020 at 16:38
  • 1
    This is not an answer to "How can I disable systemd-resolved in Ubuntu 17.04?" Commented Feb 17, 2022 at 16:19

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 To set the router as dns, create the file "tail" in your /etc/resolvconf/resolv.conf.d/ folder adding the line nameserver

do ln -sf /var/run/resolved/resolv.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 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 Commented Sep 6, 2017 at 14:42
  • 1
    yes 'default' enables as dns
    – Yvain
    Commented Sep 8, 2017 at 17:33
  • I think I am wrong here
    – Yvain
    Commented Oct 4, 2021 at 15:46
  • Please link to the "first" answer - the order of answers can change... Commented Nov 3, 2021 at 15:03

I feel compelled to add this excellent answer appearing on a dupe, it covers the case where you want the minimal setup of ifupdown + dhclient + resolvconf (yes this is still possible in 2021 in Ubuntu Focal).

This use case isn't covered by the other answers. Maybe we should strive to provide non-systemd-resolved setups for most of the different combinations we could want in our networking stack (netplan-based, networkmanager-based, wicd, and so on).


  • That is so not the systemd way! ;-) Maybe you are thinking this is Devuan? devuan.org
    – BISI
    Commented Dec 4, 2021 at 19:55
  • @BISI heh, as much as I appreciate the Devuan effort, I still feel a profound satisfaction everytime I can verify that the more mainstream distros continue to be very hackable :)
    – ata
    Commented Apr 14, 2022 at 19:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .