Chapter 4: Linux Name Services
One of the most fundamental services on a TCP/IP network is
translates hostnames into IP addresses. In Chapter 3, "Login Services," we configured telnet and
ftp. Without name service, a user connecting to crow enters
name service. It is the service thattelnet 172.16.5.5
With name service, that same command is
telnet crow
The result is the same. In either case, the user connects to the host at address 172.16.5.5. But most
users prefer hostnames because they are easier to remember and easier to use. This is particularly
true in the global Internet. It is possible to guess that http://www.sybex.com/ is a valid name, but
there is no intuitive way to guess the address 206.100.29.83.
Linux systems use two techniques to convert hostnames to addresses: the host table and the
Domain Name System (DNS). The /etc/hosts file is a table that maps names to addresses. It is a
simple text file that is searched sequentially to match hostnames to IP addresses. The Domain
Name System is a hierarchical, distributed database system with thousands of servers across the
Internet, handling name and address queries. DNS is far more important than the host table for the
operation of the Internet, but both services play a role. This chapter's discussion of name services
begins with a quick look at the host table.
The
hosts FileEach entry in the /etc/hosts file contains an IP address and the names associated with that address.
For example, the host table on crow might contain the following entries:
Listing 4.1: A Sample Host Table
$ cat /etc/hosts
127.0.0.1 localhost localhost.localdomain
172.16.5.5 crow.foobirds.org crow
172.16.5.1 wren.foobirds.org wren
172.16.5.2 robin.foobirds.org robin
172.16.5.4 hawk.foobirds.org hawk
The first entry in this table assigns the name localhost to the address 127.0.0.1. (Every computer
running TCP/IP assigns the loopback address to the hostname localhost.) Network 127 is a special
network address reserved for the loopback network, and host 127.0.0.1 is the loopback address
reserved for the local host. The
computer to address itself in exactly the same way that it addresses remote computers. This
simplifies software because the same code can be used to address any system, and because the
address is assigned to a software loopback interface (lo), no traffic is sent to the physical network.loopback address is a special convention that permits the local
No comments:
Post a Comment