Centos 6/RHEL Hosts file

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 www.example1.lan www.example2.lan www.example3.lan www.example4.lan

or you can use an external address such as    minimallinux.blogspot.com

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 and you want to restrict access to it, then simply make the following changes to the hosts file of the viewing computer       www.website.com

This isn't completely failsafe but anyone trying to access www.website.com will automatically be sent to instead of

Labels: ,