3.2 The Host Table
The
host table
is a simple text file that associates IP
addresses with hostnames. On most UNIX systems, the table is in the
file
/etc/hosts
.
Each table entry in
/etc/hosts
contains an IP address
separated by whitespace from a list of hostnames associated with that
address. Comments begin with The host table on peanut might contain the following entries:
# # Table of IP addresses and hostnames # 172.16.12.2 peanut.nuts.com peanut 127.0.0.1 localhost 172.16.12.1 almond.nuts.com almond loghost 172.16.12.4 walnut.nuts.com walnut 172.16.12.3 pecan.nuts.com pecan 172.16.1.2 filbert.nuts.com filbert 172.16.6.4 salt.plant.nuts.com salt.plant salt The first entry in the sample table is for peanut itself. The IP address 172.16.12.2 is associated with the hostname peanut.nuts.com and the alternate hostname (or alias) peanut . The hostname and all of its aliases resolve to the same IP address, in this case 172.16.12.2. Aliases provide for name changes, alternate spellings, and shorter hostnames. They also allow for "generic hostnames." Look at the entry for 172.16.12.1. One of the aliases associated with that address is loghost . loghost is a special hostname used by the syslog daemon, syslogd . Programs like syslogd are designed to direct their output to the host that has a certain generic name. You can direct the output to any host you choose by assigning it the appropriate generic name as an alias. Other commonly used generic host names are lprhost , mailhost , and dumphost . The second entry in the sample file assigns the address 127.0.0.1 to the hostname localhost . As we have discussed, the class A network address 127 is reserved for the loopback network. The host address 127.0.0.1 is a special address used to designate the loopback address of the local host - hence the hostname localhost . This special addressing convention allows the host to address itself the same way it addresses a remote host. The loopback address simplifies software by allowing common code to be used for communicating with local or remote processes. This addressing convention also reduces network traffic because the localhost address is associated with a loopback device that loops data back to the host before it is written out to the network. Although the host table system has been superseded by DNS, it is still widely used for the following reasons:
The old host table system is inadequate for the global Internet for two reasons: inability to scale and lack of an automated update process. Prior to adopting DNS, the Network Information Center (NIC) maintained a large table of Internet hosts called the NIC host table . Hosts included in the table were called registered hosts , and the NIC placed hostnames and addresses into this file for all sites on the Internet. Even when the host table was the primary means for translating hostnames to IP addresses, most sites registered only a limited number of key systems. But even with limited registration, the table grew so large that it became an inefficient way to convert host names to IP addresses. There is no way that a simple table could provide adequate service for the enormous number of hosts in today's Internet. Another problem with the host table system is that it lacks a technique for automatically distributing information about newly registered hosts. Newly registered hosts can be referenced by name as soon as a site receives the new version of the host table. However, there is no way to guarantee that the host table is distributed to a site. The NIC didn't know who had a current version of the table, and who did not. This lack of guaranteed uniform distribution is a major weakness of the host table system. Some versions of UNIX provide the command htable to automatically build /etc/hosts and /etc/networks from the NIC host table. htable and the NIC host table are no longer used to build the /etc/hosts file. However, the command is still useful for building /etc/networks . The /etc/networks file is still used to map network addresses to network names because many network names are not included in the DNS database. To create the /etc/networks file, download the file ftp://rs.internic.net/netinfo/networks.txt into a local work directory. Run htable networks.txt . Discard the hosts file and the gateways file produced by htable , and move the networks file to the /etc directory. This is the last we'll speak of the NIC host table: it has been superseded by DNS. All hosts connected to the Internet should use DNS. |
|