Fixing /etc/resolv.conf on Ubuntu 22.04 from command line

Why does /etc/resolv.conf keep changing after reboot ?

Issue is systemd-resolved - on latest Ubuntu system, it is what handling resolv.conf settings. And /etc/resolv.conf actually is a symlink to /run/systemd/resolve/resolv.conf managed by systemd-resolved

Yes, I know - it is painful. Once you are rebooting server - /etc/resolv.conf resetting to the previous configuration, most probably like following

nameserver 127.0.0.53

To fix, 1st, check /etc/systemd/resolved.conf. Enable DNS and FallbackDNS

DNS=1.1.1.1 8.8.8.8
FallbackDNS=208.67.222.222
#Domains=
#DNSSEC=no
#DNSOverTLS=no
#MulticastDNS=no
#LLMNR=no
#Cache=no-negative
#CacheFromLocalhost=no
#DNSStubListener=yes
#DNSStubListenerExtra=
#ReadEtcHosts=yes
#ResolveUnicastSingleLabel=no

Then,

Restart system resolved: service systemd-resolved restart

Still not resolved ? Ok - try following and 90% chances that problem will be fixed.

rm -f /etc/resolv.conf
ln -sv /run/systemd/resolve/resolv.conf /etc/resolv.conf