DANGER: Do not manually make changes to /etc/resolv.conf.
ls -al /etc/resolv.conf
returns:
lrwxrwxrwx 1 root root 32 Jan 10 18:50 /etc/resolv.conf -> /run/systemd/resolve/resolv.conf
NOTE: This shows that /etc/resolv.conf is a symlink to /run/systemd/resolve/resolv.conf.
It may instead be a symlink to /run/systemd/resolve/stub-resolv.conf. Also ok.
If not then to fix try:
sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
cat /etc/resolv.conf
returns:
# This file is managed by man:systemd-resolved(8). Do not edit. # # This is a dynamic resolv.conf file for connecting local clients directly to # all known uplink DNS servers. This file lists all configured search domains. # # Third party programs must not access this file directly, but only through the # symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way, # replace this symlink by a static file or a different symlink. # # See man:systemd-resolved.service(8) for details about the supported modes of # operation for /etc/resolv.conf. nameserver 192.168.1.1 search localdomain
NOTE: If the nameserver is 127.0.0.53 then this is fine too - It is set as default by Ubuntu.
Usually it would only show as 192.168.1.1 or similar if DNS changes had been made in networking settings; such as in /etc/netplan.
Edit the /etc/resolvconf/resolv.conf.d/head file.
NOTE: Ignore the scary warning.
/etc/resolv.conf is auto-generated; so the warning is there so it will get put in /etc/resolv.conf when /etc/resolv.conf is generated.
To the end of the file, add:
nameserver <ip_of_nameserver>
NOTE: Resolvconf has a /etc/resolvconf/resolv.conf.d/ directory that can contain “base”, “head”, “original” and “tail” files. All in resolv.conf format.
Regenerate /etc/resolv.conf so the changes are applied right now:
sudo resolvconf -u
To make DNS configuration changes for some common use cases:
WARNING: Disabling resolvconf is not recommended, but you can replace the symlink /etc/resolv.conf with a regular file.
setup nslookup or dig command:
dig www.google.com
nslookup www.google.com