Skip to main content
IBM  
Shop Support Downloads
IBM Home Products Consulting Industries News About IBM
IBM developerWorks : Linux : Education - Tutorials
LPI certification 102 exam prep, Part 3
ZIPPDF (letter)PDF (A4)e-mail
Main menuSection menuFeedbackPreviousNext
2. TCP/IP networking
  


Name resolution limitations page 8 of 11


However, while you'll be able to type things like ping 192.168.1.1, you won't be able to refer to your boxes by name. For example, you won't be able to type ping mybox. To do this, you need to set up a file called /etc/hosts on each of your Linux boxes. In this file, you specify an IP address, along with the name (or names) that are associated with each IP address. So if I had a network with three nodes, my /etc/hosts file might look something like this:

 
127.0.0.1 		 		 localhost 
192.168.1.1 		 		 mybox mybox.gentoo.org 
192.168.1.2 		 		 testbox testbox.gentoo.org 
192.168.1.3		 		 mailbox mailbox.gentoo.org 

Note that /etc/hosts contains an obligatory mapping of "localhost" to the 127.0.0.1 IP address. I've also specified the hostnames of all the systems on my LAN, including both their short name ("mybox") and their fully-qualified name ("mybox.gentoo.org"). After copying this /etc/hosts file to each of my systems, I'll now be able to refer to my systems by name, rather than simply by IP address: ping mybox will now work!


Main menuSection menuFeedbackPreviousNext
Privacy Legal Contact