Tuesday, September 13, 2011

The /etc/hosts file

If you are not using DNS server for connecting to other nodes in the network then chances are you are using the configuration of the /etc/hosts file for node connectivity.

This is especially useful for small sites. In this setup every node of the network keeps its own copy of the hosts file which contains the hostname and IP address in the /etc/hosts file of all the nodes which are part of network.

The structure of the /etc/hosts file is very simple. It consists of basically three columns the IP address, their corresponding hostname and the third column generally stores the short version of the hostname.

For example in a simple network of two nodes node1.oracle.com and node2.oracle.com with IP address 192.9.201.5 and 192.9.201.6 respectively then the /etc/hosts of each node file will look like this:

127.0.0.1              localhost.localdomain               localhost
::1                          localhost6.localdomain6           localhost6

192.9.201.5          node1.oracle.com                    node1
192.9.201.6          node2.oracle.com                    node2

In the above file the address 127.0.0.1 is to specify the loopback address for IPv4.
The ::1 is the loopback address for IPv6.

No comments:

Post a Comment