≡ Menu

How to set or update DNS servers on Linux?

Each operating system comes with a way of updating the DNS servers that the OS will use to perform name lookups. DNS is a protocol based upon UDP which allows you to convert a domain name to an IP Address.

On Linux, there is a file called the following:

/etc/resolv.conf

This file contains the IP addresses of the name servers that the system will use to perform DNS queries. This file is common between all distributions of Linux like Debian, CentOS or Ubuntu.

On my system, this file looks like the following:

[root@server ~]# cat /etc/resolv.conf
nameserver 199.167.198.1
nameserver 4.2.2.1
[root@server ~]#

So there are two name servers configured in the file. In most cases, this file will be populated using your ISP’s name servers (the name servers provided by your internet service provider). Note that you should not put in names in this file, but only IP addresses. Depending on whether your network is IPv6 enabled or not, you could be able to put in both IPv4 and IPv6 addresses in this file. To be on the safe side, use only IPv4 addresses until you are sure that your server provider has support for IPv6 networking.

You can also change this file to use Google Public DNS name servers:

nameserver 8.8.8.8
nameserver 8.8.4.4

The above two IP addresses are the addresses of Google’s public DNS name servers.

{ 0 comments… add one }

Leave a Comment