Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
How to disable systemd-resolved in Ubuntu

How to disable systemd-resolved in Ubuntu


  • Disable and stop the systemd-resolved service:

      sudo systemctl disable systemd-resolved.service
      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 network-manager

      sudo service network-manager restart


Copy link

nelebadnjak commented Mar 10, 2020

This is wrong, instead of dns=none it should be dns=default

Copy link

zoilomora commented Mar 10, 2020

This is wrong, instead of dns=none it should be dns=default

Yes, I don't know what happened at the time of writing, but currently I have dns=default, thanks for warning!

Copy link

tweakunwanted commented Apr 2, 2020

what is dns=default tho? I use on my resolv.conf and want to keep using that

Copy link

zoilomora commented Apr 2, 2020

@tweakunwanted you can see the documentation of NetworkManager. If you don't want /etc/resolv.conf to be changed, assign dns=none.

Copy link

antonalechnovic commented May 10, 2020

Thanks for fixing my VPN wish I'd find this 2 hours before.

Copy link

sej7278 commented Aug 9, 2020

Any idea how to do this on centos8 - even systemctl mask systemd-resolved doesn't fix it, none of the above does either and /etc/resolv.conf isn't a symlink on centos8, dns=none is the default

Copy link

JakeSays commented Oct 6, 2020

This just saved my butt. For some reason resolved just decided to stop working. After two hours of pain killing resolved did the trick. Yet one more reason why I hate systemd. Just want it do die a painful death.

Copy link

dag-erling commented Oct 13, 2020

Just a nit: I find it odd that you use service to restart NetworkManager and not systemctl since the former is just a compatibility wrapper around the latter.

Copy link

sanfx commented Oct 31, 2020

this has started causing

sudo service network-manager restart
sudo: unable to resolve host ubuntu-18-04: Resource temporarily unavailable

Copy link

mdPlusPlus commented Nov 15, 2020

Worked like a charm on Kubuntu 20.04.1 LTS.

Copy link

ajbogh commented Dec 3, 2020

Just a note in case people need to undo these instructions:

The symlink for /etc/resolv.conf points to ../run/systemd/resolve/stub-resolv.conf

/etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf

Copy link

torressam333 commented May 23, 2021

This was helpful, I was trying to configure vhosts using network manager and the missing piece was deleting the symlink from systemd. Thanks!

Copy link

Clifra-Jones commented Oct 14, 2021

I don't know why but ever since returning to the office (I'm on WIFI because someone let the cable fall behind the desk) I lose DNS resolution. It works for a few minutes then fails. This seems to have fixed it. Thanks!

Copy link

ahmathlete commented Oct 25, 2021

dns=none worked for me even after restarting the network-manager. However, dns=default set the nameserver to restarting it.

Copy link

code-eren commented Nov 16, 2021

I got network-manager: unrecognized service on ubuntu18.04, what should I do?
try to fix the chromium-based brower bug
[1116/] open /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq: No such file or directory (2)
[1116/] open /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq: No such file or directory (2)

Copy link

Maxl94 commented Nov 18, 2021


sudo service network-manager restart

Did not work for me with Ubuntu 21.10. I used the command from the source of this gist.

sudo systemctl restart NetworkManager

Copy link

martijn commented Jan 12, 2022

Thanks, this resolved VPN-issued DNS servers not being used in Docker containers for me on Pop_OS! 21.10.

Copy link

thekoma commented Mar 4, 2022

If anyone wants to do it extra quick I wrote a little playbook:

# apt/yum install ansible, then:
curl -L > disable-systemd-resolved.yaml
ansible-galaxy collection install community.general
ansible-playbook -v disable-systemd-resolved.yaml

Copy link

mdPlusPlus commented Mar 7, 2022

@thekoma: I'd advise everyone to no to use URL shorteners when it comes to blind code execution on user's machines. The content that hides behind that URL could change at any moment in time and could become malicious.

Copy link

thekoma commented Mar 7, 2022

It's not blind. I'm not piping into bash. I've just shortened the gist url which is marked in the first statement.
But if you prefer:

Copy link

leroy0211 commented Mar 23, 2022

We did not have NetworkManager service installed (fresh ubuntu 20.04). We kept the systemd-resolved service running and changed the /etc/resolv.conf symlink to use another resolv.conf file.

Default symlink was this:

/etc/resolv.conf  ->  ../run/systemd/resolve/stub-resolv.conf

We changed it to:

/etc/resolv.conf  ->  ../run/systemd/resolve/resolv.conf

This means we don't use a cached resolver, but we keep using the generated resolv.conf file from the systemd-resolved service. Which is overwritten/managed by netplan.

Original issue

We are running applications in docker which could not connect to any internally hosted applications on their local DNS name. Docker documentation about DNS:

By default, a container inherits the DNS settings of the host, as defined in the /etc/resolv.conf configuration file [..] If the container cannot reach any of the IP addresses you specify, Google’s public DNS server is added, so that your container can resolve internet domains.

We discovered using journalctl -xeu docker that docker was using google's DNS, so we figured that docker was not able to reach the configured DNS service. Which is correct. The /etc/resolv.conf file which was using nameserver also for docker, resolves to the docker container and not the guest host.

Copy link

kimboslice99 commented Nov 13, 2022

Following these steps on a fresh Ubuntu 22.10 install completely breaks dns

Local dns servers are perfectly functional, Ubuntu sees them and they show in network config, but it refuses to use them, what gives?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment