UNIX System Administration Handbook - Evi Nemeth [181]
The process of designing and installing a physical network is touched on in Chapter 15, Network Hardware. If you are dealing with an existing network and have a general idea of how it is set up, it may not be necessary for you to read too much more about the physical aspects of networking unless you plan to extend the existing network.
We describe the process of network configuration in terms of Ethernet; other technologies are essentially similar.
Assigning hostnames and IP addresses
Administrators have various theories about how the mapping from hostnames to IP addresses is best maintained at a local site: the hosts file, NIS or NIS+, the DNS system, or perhaps some combination of those sources. If multiple systems are used, there must also be a sensible plan for how they are to work together. The conflicting values are scalability and maintainability versus a system that is flexible enough to allow machines to boot when not all services are available (and flexible enough to handle the heterogeneity of your site).
See Chapter 16 for more information about DNS.
The /etc/hosts file is the oldest and simplest way to map names to IP addresses. Each line starts with an IP address and continues with the various symbolic names by which that address is known. Here is a typical minimalist /etc/hosts file for the host lollipop:
127.0.0.1 localhost
192.108.21.48 lollipop.xor.com lollipop loghost
192.108.21.254 chimchim-gw.xor.com chimchim-gw
192.108.21.1 ns.xor.com ns
192.225.33.5 licenses.xor.com license-server
It is common to have localhost as the first entry in the /etc/hosts file; on some systems, it is even rumored to be necessary (FreeBSD, for example).
Because /etc/hosts contains only local mappings, most modern systems use it only for mappings that are needed at boot time. DNS is then consulted to find mappings for the rest of the local network and the rest of the world. Sometimes /etc/hosts is used to specify mappings that you do not want the rest of the world to know about and therefore do not publish in DNS.
/etc/hosts is important during the boot process because DNS is not yet available. It must contain at least the mapping for the host itself and for the loopback address. In addition, it should probably contain the mappings for the default gateway machine and a name server. Many sites put all of their really important hosts, servers, and gateways in the /etc/hosts file. Others put only the host itself and the loopback interface; still others add in all local hosts and their off-site backup name servers.
If your /etc/hosts file contains all your local data, it must be replicated on every machine that wants to use symbolic names. Various schemes allow a single version of the hosts file to be kept in a central location and distributed to or shared by other hosts at your site; see Chapter 18, Sharing System Files, for more information. DNS is really the “correct” way to manage the mapping. Chapter 16 describes DNS and BIND, its UNIX implementation, in detail.
The hostname command assigns a hostname to a machine. hostname is typically run at boot time from one of the startup scripts, which obtains the name to be assigned from a configuration file. Of course, each vendor names that configuration file differently. See the vendor-specific sections beginning on page 306 for information about your specific system. Most systems today assign a fully qualified name (that is, a name that includes both the hostname and the DNS domain name, such as anchor.cs.colorado.edu).
At a small site, you can easily dole out hostnames and IP addresses by hand. But when many networks and many different administrative groups are involved, it helps to have some central coordination. Colorado’s home-grown addhost system is a set of distributed tools that solve several of the problems of host management. DHCP is another way to solve this problem, and LDAP would also work. addhost is pretty old and crufty, but it is still in use at several sites; if you don’t find