I am running Ubuntu server 20.04 on a Raspberry Pi 4 and I am having difficulty updating the DNS entry in resolv.conf
. resolv.conf
points to the nameserver 127.0.0.53
; however, I disabled the systemd-networkd dnsstublistener
so I could run my own DNS server. How can I change the nameserver to point to 127.0.0.1
instead?
Asked
Active
Viewed 2.5k times
11
2 Answers
12
Use netplan
instead of resolv.conf
cd /etc/netplan
ls
sudo nano 50-cloud-init.yaml
Add nameservers
entry.
network:
ethernets:
[network-device]:
...
nameservers:
addresses:
- 2001:4860:4860::8888
- 2001:4860:4860::8844
- 8.8.8.8
- 8.8.4.4
Then to apply and test:
sudo netplan apply
systemd-resolve --status

User Rebo
- 256
5
I discovered that my changes were not being applied to resolv.conf
because of a symbolic link issue. To fix, I first deleted the file /etc/resolv.conf
, which was a symbolic link to /run/systemd/resolve/stub-resolv.conf, and then created a new link to /run/systemd/resolve/resolv.conf.
sudo rm /etc/resolv.conf
sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf