CentOS uses the hosts file to resolve hostnames locally before trying to resolve them from a dns server in /etc/resolv.conf.
Traditionally, I preferred to not setup much in /etc/hosts and primarily use DNS for name resolution. But with the growing popularity of configuration management tools like puppet and chef, it isn’t difficult to maintain a consistent hosts file across an environment which helps lighten the load on DNS servers.
The format is simply ip address, followed by hostnames per line.
# we want the localhost ip address 127.0.0.1 to resolve as localhost
# we also want this server websrv01.centoshowtos.org to resolve to its RFC1918 address 10.66.6.25
10.66.6.25 websrv01 websrv01.centoshowtos.org
With websrv01 entered into hosts, we can resolve it a few different ways.
Both of these will resolve 10.66.6.25(Comments)