9.7. The /etc/hosts file

As your machine gets started, it will need to know the mapping of some hostnames to IP addresses before DNS can be referenced. This mapping is kept in the /etc/hosts file. In the absence of a name server, any network program on your system consults this file to determine the IP address that corresponds to a host name.

Following is a sample /etc/hosts file:

           IPAddress     Hostname    		 Alias
           127.0.0.1			localhost	 	 deep.openna.com
           208.164.186.1		deep.openna.com		 deep
           208.164.186.2		mail.openna.com		 mail
           208.164.186.3		web.openna.com		 web
           
The leftmost column is the IP address to be resolved. The next column is that host's name. Any subsequent columns are alias for that host. In the second line, for example, the IP address 208.164.186.1 is for the host deep.openna.com. Another name for deep.openna.com is deep.

After you are finished configuring your networking files, don't forget to restart your network for the changes to take effect.
           
           [root@deep] /# /etc/rc.d/init.d/network restart
           

             
           Setting network parameters		 [  OK  ]
           Bringing up interface lo		 [  OK  ]
           Bringing up interface eth0	         [  OK  ]
           Bringing up interface eth1	         [  OK  ]
           
           

Important: Time out problems for telnet or ftp connection are often caused by the server trying to resolve the client IP address to a DNS name. Either DNS isn't configured properly on your server or the client machines aren't known to DNS. If you intend to run telnet or ftp services on your server, and aren't using DNS, don't forget to add the client machine name and IP in your /etc/hosts file on the server or you can expect to wait several minutes for the DNS lookup to time out, before you get a login: prompt.