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: 



Example:


If we don't mention any DNS server, the default one - "8.8.8.6" - 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:


Example:

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


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

                       

DNS configuration files:

"/etc/hosts":

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



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

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 .

/etc/revolv.conf:

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.

Remark:

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


Brando Sabatini and Ikbal C ©. Powered by Blogger.