The hosts file consists of a list of IP addresses and corresponding hostnames and if your network contains computers whose IP addresses are not listed in an existing DNS record, in order to speed up the network it is recommended that you add them to the hosts file.
To do this on Centos just open up the hosts file and add the following values
$ sudo /etc/hosts
or you can use an external address such as
This method provides you with the chance to create mappings between domain names and IP addresses without the need to use a DNS and can be applied to any workstation or server.
The list is not restricted by size and and you can even employ this method to block access to certain websites by simply repointing all requests to visit a known website to a different IP address. For example, if the real address of www.website.com is 192.168.1.200 and you want to restrict access to it, then simply make the following changes to the hosts file of the viewing computer
This isn't completely failsafe but anyone trying to access www.website.com will automatically be sent to 192.168.1.201 instead of 22.214.171.124
Labels: Centos 6, RHEL Hosts file