Here’s a quick tutorial for a simple but important task – manually setting the DNS server on your Linux system.
The steps in this tutorial should work for all Linux distributions – both server and desktop.
Backup Existing DNS Configuration
If an existing manual DNS configuration exists, back it up by copying it to a new file:
sudo cp /etc/resolv.conf /etc/resolv.conf.bak
Edit Linux DNS Configuration
The nano text editor will edit or create a text file:
sudo nano /etc/resolv.conf
If no configuration is set, the editor may be empty. If there is an existing DNS configuration it will look something like this:
nameserver 126.96.36.199 nameserver 188.8.131.52
Above, the primary and secondary DNS servers are set to use Google’s DNS service. The primary DNS server is on the first line, the secondary on the second line.
You can edit these values to be whatever you want For example, if you have set up your own DNS server (for example, to so set up ad blocking with Pi-Hole) at 192.168.1.202, your configuration might look like this:
nameserver 192.168.1.202 nameserver 184.108.40.206
I’ve left the secondary DNS server as Google’s, so if my own DNS server fails, or is unable to perform a lookup, it will be used instead.
Save by pressing Ctrl+X and then Y to confirm then reboot your computer: