You can install the resolvconf package, which will modify the way /etc/resolv.conf
is built up at system boot.
sudo apt install resolvconf
You can then create or modify a file /etc/resolvconf/resolv.conf.d/tail
. If you put in this file a line nameserver 8.8.8.8
, this line will be added at the end of /run/resolvconf/resolv.conf
at boot. /etc/resolv.conf
will now be a symbolic link to this file.
Post Scriptum:
Almost two years after posting my answer I came across https://bugs.launchpad.net/ubuntu/+source/ppp/+bug/1778946 which explains exactly why merely installing resolvconf
solved a dns problem I had at the time. I feel I have to share this here.
Although my answer addresses the question in a proper way, indeed a
warning should be added that, if you want/need to do this, probably
something else is wrong. This was already stated by @intelfx at the
time, 127.0.0.53 should work by itself.
According to that bug report, after a PPTP VPN goes down, resolv.conf
is restored with the wrong access rights. ping ubuntu.com
does not work, sudo ping ubuntu.com
does. Installing resolvconf
solved it, because it takes over resolv.conf
, restoring it with correct rights. Changing systemd-resolve
settings is no solution in this case, since the bug is in ppp
. But an alternative, maybe simpler solution is sudo chmod a+r /etc/resolv.conf
after VPN down. And this can be automated by putting an executable script in /etc/NetworkManager/dispatcher.d with contents:
#!/bin/sh
if [[ "$1"="ppp0" && "$2"="vpn-down" ]]; then
/bin/chmod a+r /etc/resolv.conf
fi
In all cases, the contents of resolv.conf
do not change.
And, yes, I know PPTP must be avoided because of security issues, but at the time I thought of it as a good exercise for an Ubuntu newbie. I imagined it would work out of the box. Little did I know that it would give me a headache, as diagnosed so well by @intelfx.
systemctl stop systemd-resolved
andsystemctl mask systemd-resolved
should do the trick :)