0

Ubuntu 20.04 LTS /etc/resolv.conf is getting overwritten after either netplan apply or server reboot. We are not using networkmanager.

We did the following changes not sure if this will help:

sudo unlink /etc/resolv.conf
sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
sudo systemctl restart systemd-resolved
sudo systemctl enable systemd-resolved

Add DNS in netplan and do sudo netplan apply.

Artur Meinild
  • 26,018
S M
  • 1

1 Answers1

1

As the /etc/resolv.conf said, you shouldn't edit that file as is managed by Systemd. Add your DNS configuration on /etc/systemd/resolved.conf. A better practice would not be editing the original configuration file but create another one, like /etc/systemd/resolved.conf.d/dns_servers.conf

[Resolve]
DNS=8.8.8.8

Remember to restart the service with sudo systemctl restart systemd-resolved

Ockham
  • 11
  • thanksAs the /etc/resolv.conf said, you shouldn't edit that file as is managed by Systemd. Add your DNS configuration on /etc/systemd/resolved.conf. A better practice would not be editing the original configuration file but create another one, like /etc/systemd/resolved.conf.d/dns_servers.conf

    [Resolve] DNS=8.8.8.8 ---> can i add my namesserver Remember to restart the service with sudo systemctl restart systemd-resolved

    – S M Nov 16 '22 at 13:46
  • Yes, you can add whatever DNS you want. – Ockham Nov 16 '22 at 19:32
  • thanks we dont have network manager, i hope this will work – S M Nov 17 '22 at 05:37