Linux 101 : DNS overview - dig, nslookup -

Testing DNS using the default server:

To test whether the DNS server is working properly, we could use the "dig" utility that resolves a hostname and returns its IP address, along with some other information: 


If we don't mention any DNS server, the default one - "" - in "/etc/revolv.conf" will be used:

Using "nslookup" To test the DNS server:

We could also use the nslookup tool as below to test our DNS server:

If we omit the "dns-server", the default one in the "/etc/revolv.conf" file will be used.

The "host" utility:

The "host" utility is a simple tool that could be used instead of "dig" to get the IP address of a host as we can see below:


Using the default DNS from the "/etc/resolv.conf" file:

We could also make the request to a specific DNS server - - as below:


DNS configuration files:


The file contains a mapping between IP addresses and URLs as we can see below:

If we add for example a line with "", it will keep us from accessing "" since it will be mapped to the wrong address "".

Before the system looks up an address via DNS, it checks the "/etc/hosts" file first as stated in the "/etc/nsswitch.conf" file.

"/etc/nsswitch.conf" :

One of the roles of the "/etc/nsswitch.conf " file is that it specifies the order in which the system does the DNS lookup:

The above line for example, means that the system tries to resolve a DNS name by first  looking in the "/etc/hosts" file, before querying the DNS server mentioned in the "/etc/revolv.conf" file .


The "/etc/revolv.conf" file contains a list of name servers. We don't have to edit the file manually, it is populated automatically by the "systemd-resolve" service.


If we change the DNS configuration files, we would need to restart the DNS server using the below command:


Leave as a comment: