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

192.168.1.100 www.example1.lan
192.168.1.101 www.example2.lan
192.168.1.102 www.example3.lan
192.168.1.103 www.example4.lan

or you can use an external address such as

74.125.239.44    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 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

192.168.1.201       www.website.com

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








Labels: ,