Adding Additional Nameservers to resolv.conf on Linux


Resolv.conf

If you need to add additional nameservers to your resolv.conf because of DNS related issues, you'll want to use a package that manages the file at /etc/resolv.conf. This is because on system restart, the file will be overwritten by other processes and you will lose any previous changes.

Install and Enable Resolvconf Package

sudo apt update
sudo apt install resolvconf

Check if it is running

sudo systemctl status resolvconf

Enable the service.

sudo systemctl enable resolvconf.service

Add Additonal Nameservers

Open /etc/resolvconf/resolv.conf.d/head and add the nameservers you want.

nameserver 8.8.8.8 
nameserver 8.8.4.4

Save the changes and then restart the service.

sudo systemctl restart resolvconf

Check the /etc/resolv.conf to verify your nameservers have been added now.

If so, you are all set!

  • Image from neowin.net