Skip to content

Instantly share code, notes, and snippets.

@zoilomora
Last active April 25, 2024 08:17
Show Gist options
  • Save zoilomora/f7d264cefbb589f3f1b1fc2cea2c844c to your computer and use it in GitHub Desktop.
Save zoilomora/f7d264cefbb589f3f1b1fc2cea2c844c to your computer and use it in GitHub Desktop.
How to disable systemd-resolved in Ubuntu

How to disable systemd-resolved in Ubuntu

Stages

  • 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:

      dns=default
    
  • Delete the symlink /etc/resolv.conf

      rm /etc/resolv.conf
    
  • Restart network-manager

      sudo service network-manager restart
      or
      sudo systemctl restart NetworkManager.service
    

Sources

@kimboslice99
Copy link

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?

@kyledrake
Copy link

kyledrake commented Dec 5, 2022

Don't forget to add back the resolv.conf:

echo 'search example.com' > /etc/resolv.conf
echo 'nameserver 1.1.1.1' >> /etc/resolv.conf
echo 'nameserver 1.0.0.1' >> /etc/resolv.conf

systemd-resolvwhatever broke after upgrading ubuntu, and it was easier to just switch back to the Thing That Always Worked than to try to figure it out.

@videni
Copy link

videni commented Apr 3, 2023

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?

How do you solve the DNS issue for 22.10 please?

@euntae
Copy link

euntae commented Nov 30, 2023

root@www::> systemctl disable systemd-resolved
root@www:
:> systemctl stop systemd-resolved
root@www::> rm -f /etc/resolv.conf
root@www:
:> cat < /etc/resolv.conf
nameserver 9.9.9.9
nameserver 8.8.8.8
nameserver 1.1.1.1
EOF
root@www:~:> reboot

@andry81
Copy link

andry81 commented Jan 30, 2024

Why not just rename instead of remove?

mv /etc/resolv.conf /etc/resolv.conf.del

@STPKITT
Copy link

STPKITT commented Apr 22, 2024

@euntae: With just stopping instead of also disabling systemd-resolved it will be active again after a reboot but the way you described it the entries in resolv.conf won't get used anyway at least on Ubuntu 24.

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