There are three main client configuration files associated with DNS: /etc/hosts, /etc/nsswitch.conf and /etc/resolv.conf. When your computer looks for another computer on a TCP/IP network such as the Internet, it typically looks in two places: /etc/hosts and any DNS servers that you've set up for your network.
The /etc/hosts file keeps a local name database. This file helps in local name resolution if your local DNS server is not functioning. Network adinistrators should manually populate entries in this file. A sample /etc/hosts file is copied below.
[[email protected] ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
192.168.1.1 RHEl01.omnisecu.com RHEL01
192.168.1.105 RHEL05.omnisecu.com RHEL05
192.168.1.106 RHEL06.omnisecu.com RHEL06
192.168.1.107 RHEL07.omnisecu.com RHEL07
192.168.1.108 RHEL08.omnisecu.com RHEL08
192.168.1.109 RHEL09.omnisecu.com RHEL09
The order of name resolution process is determined by a single line in /etc/nsswitch.conf:
In this case, the name resolution process will begin with checking /etc/hosts file, and if the name cannot be resolved, the name resolution will happen with the DNS server.
The /etc/resolv.conf file contains directives with the IP addresses of nameservers available to a host. A sample /etc/resolv.conf file is copied below.
[[email protected]RHEL01 ~]# cat /etc/resolv.conf