Resolv.conf deprecated
resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8) # DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN nameserver 127.0.1.1 search Home
Before systemctl was implemented, you would put the DNS nameservers in resolv.conf
Since the implementation of systemctl the resolv.conf file is no longer user edited. The package that makes the change is called resolvconf.
Although the /etc/resolv.conf file still exists, it is no longer where you configure your DNS nameservers.
Contents
network interfaces file (doesn't work in Ubuntu 18.04 or later )
If you are using the "ifup" method you can directly edit the network interfaces file.
sudo vi /etc/network/interfaces sudo /etc/init.d/networking restart
Netplan method
Distributions such as Ubuntu started using a system called netplan as of 18.x. With netplan network configurations are handled in one location (each interface having their own configuration file).
ls /etc/netplan
Formatting is very critical in these files, indentation is all important.
After you edit the network configuration files in netplan you can reload by issuing:
sudo netplan apply
Or alternatively you can do testing with
sudo netplan --debug apply
resolvconf method (not recommended)
A script called /etc/network/if-up.d/000resolvconf is responsible for overwriting resolv.conf
see: /sbin/resolvconf -a "${IFACE}.${ADDRFAM}"
It is possible to specify base DNS servers for resolvconf at /etc/resolvconf/resolv.conf.d/base, which won't be overwritten.
It uses the same syntax. That way you can keep running Ubuntu or Mint the default way. Then tell resolvconf to regenerate resolv.conf with sudo resolvconf -u.
Hover, you can remove resolvconf: sudo apt-get remove resolvconf. It is safe to do so. Then write your desired DNS resolvers into /etc/resolv.conf
STEPS TO MANUALLY ADDING DNS SERVER USING /etc/resolvconf/resolv.conf.d/base
1. Open the file in the editor
sudo vi /etc/resolvconf/resolv.conf.d/base
2. add the DNS server you desire and save
nameserver 8.8.8.8
3. force reload so it writes to /etc/resolv.conf
resolvconf -u
Other Annoying Changes by the Nerds
The ifconfig command has been replaced by the ip command. To show your IP address type:
ip addr show
To get the DNS addresses associated with an interface type the following:
nmcli device show <interface> | grep IP4.DNS