These classnotes are depreciated. As of 2005, I no longer teach the classes. Notes will remain online for legacy purposes

UNIX02/The Hosts File

Classnotes | UNIX02 | RecentChanges | Preferences

Showing revision 1
DNS (Domain Name Service) is the standard means by which host names get resolved into IP addresses, however, you will want at least some simple host name resolution without going through a DNS server. Your Linux system may need a simple host name resolution for start up scripts, or you may want to have a more quick lookup for certain hosts, or you may even want to redirect certain host names to other hosts. This is where the /etc/hosts file comes in.

Your hosts file is a white-space separated configuration file with three columns. The first column contains the IP, the second column contains the fully qualified domain name, and the third column contains the optional aliases.

By default, you should have at least the following in your hosts file (this is the default Red Hat hosts file):

 # Do not remove the following line, or various programs
 # that require network functionality will fail.
 127.0.0.1               localhost.localdomain localhost

If you will recall, this is the looback interface that was mentionned earlier.

You may have a more complicated network, then you would have other entries in the hosts file as well. Here is an example from a ficticious Brewery company:

 #
 # Hosts file for Virtual Brewery/Virtual? Winery
 #
 # IP            FQDN                 aliases
 #
 127.0.0.1       localhost
 #
 172.16.1.1      vlager.vbrew.com      vlager vlager-if1
 172.16.1.2      vstout.vbrew.com      vstout
 172.16.1.3      vale.vbrew.com        vale
 #
 172.16.2.1      vlager-if2
 172.16.2.2      vbeaujolais.vbrew.com vbeaujolais
 172.16.2.3      vbardolino.vbrew.com  vbardolino
 172.16.2.4      vchianti.vbrew.com    vchianti


Classnotes | UNIX02 | RecentChanges | Preferences
This page is read-only | View other revisions | View current revision
Edited April 25, 2003 11:26 pm (diff)
Search:
(C) Copyright 2003 Samuel Hart
Creative Commons License
This work is licensed under a Creative Commons License.