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 - "220.127.116.11" - 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:
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 "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.
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.