The Domain Name System or DNS client is used to convert domain names into IP addresses and vice-versa. The DNS client configuration is stored in the /etc/resolv.conf file but the /etc/nsswitch.conf contains the parameter hosts which determines the source of DNS information.
The most common value of the hosts parameter in /etc/nsswitch.conf tends to be…
# grep “^hosts:” /etc/nsswitch.conf
hosts: files dns
… but depending on the company’s infrastructure decisions, we might see also 3 more values for the hosts parameter: nis, nisplus and ldap.
The setting above would use /etc/hosts to resolve IP addresses and query the DNS servers only when the hosts file fails to give a match. As a rule of thumb, we should include in /etc/hosts all the names of those internal servers with static IPs that are accessed most often from our host. This avoids unnecessary querying of the DNS servers and speeds up network communications.
The main DNS client file is pretty simple:
# cat /etc/resolv.conf
The nameserver parameter specifies a DNS server that is reachable from the current host. We can list as many as we want.
The domain parameter states the domain of the current host.
The search parameter lists the domain names to append to those queries with just a hostname without any domain.
The timeout option obviously states the number of seconds the client will wait for a reply before re-
attempting the query on the same or another server.
The attempts option specifies the number of attempts on the same DNS server before switching to another one.
Finally, the rotate option causes the DNS client to use all the listed DNS servers on a round-robin fashion rather than starting always by the first one and down the list.