Skip to content

Instantly share code, notes, and snippets.

@Spredzy
Created October 29, 2012 13:53
Show Gist options
  • Save Spredzy/3973677 to your computer and use it in GitHub Desktop.
Save Spredzy/3973677 to your computer and use it in GitHub Desktop.

/etc/hosts

whatis hosts

hosts(5)                 - host name data base

Quoting the man page :

For each host a single line should be present with the following information:

Internet address Official host name Aliases

By default your /etc/hosts file shoud look like this (IPv4 Only)

127.0.0.1 localhost 255.255.255.255 broadcasthost

It gives the IP of the 'localhost' and 'broadcasthost' hostnames. One can manually insert new entries :

192.168.1.23 paris paris.europe 192.168.1.24 london london.europe 72.232.194.162 centos.org 209.132.183.181 redhat.com

paris and london are two machines on a local network, they are not known as such by any DNS server out there. Including them on my hosts database allow my local application to talk to paris.europe without specifying the IP address (192.168.1.23)

centos.org and redhat.com are who they claim they are. Here (according to nsswitch.conf) a DNS server query is saved since the IP is on my hosts database. It was once usefull/mandatory to have those data in here, but it is not anymore even deprecated. Let the matching of Public IP Addresses to name servers. That what they're made for

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment