Changing the DNS servers Ubuntu Server 20.04 - Arm64 (Raspi)

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

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