How to Change Your DNS in Linux

How to Change Your DNS in Linux

by Chris Thomas on 30 August 2017 · 317 views

As a Linux user you're probably somewhat technically proficient, which means you should know what the Domain Name System (DNS) is and why using the right DNS servers can be so important for fast browsing and smooth connectivity. In a recent guide we talked about using Namebench and DNS benchmark to find the best performing DNS servers in your area. In this brief tutorial, we'll show you how to change our DNS settings in Linux to use new DNS servers of your choice:

In Linux your preferred DNS server IP addresses are stored within the /etc/resolv.conf file. By default this file will contain at least one pre-existing nameserver line, with each line defining a different DNS server IP address. The system will use the DNS addresses on the top nameserver line first, so it's important to arrange your best performing DNS servers at the top of the file. With that said, here's how to open and edit your resolv.conf file in Linux:

1. Open resolve.conf using a Linux text editor like nano. If the file does not yet exist in your version of Linux, you can create it by using the following command:

sudo nano /etc/resolv.conf

2. If lines already exist in the file, you can simply change the IP addresses next to the pre-existing nameserver lines. If not, you can add new lines by typing “nameserver” and then a space followed by the DNS server IP address. Each line should contain only one DNS IP address.

Pic of resolv.config being edited in gedit:

1 full How to Change Your DNS in Linux 

3. To save your changes and begin using the new DNS servers, simply save the file and the changes will take effect immediately.

Comments (0)
Featured Articles