Библиотека сайта rus-linux.net
Next: Interface Configuration for IP Up: Configuring TCP/IP Networking Previous: Assigning IP-Addresses
Even if you want to run DNS or NIS during normal operation, you want to have some subset of all hostnames in /etc/hosts nevertheless. For one, you want to have some sort of name resolution even when no network interfaces are running, for example during boot time. This is not only a matter of convenience, but also allows you to use symbolic hostnames in your rc.inet scripts. Thus, when changing IP-addresses, you only have to copy an updated hosts file to all machines and reboot, rather than having to edit a large number of rc files separately. Usually, you will put all local hostnames and addresses in hosts, adding those of any gateways and NIS servers if used.
Also, during initial testing, you should make sure your resolver only uses information from the hosts file. Your DNS or NIS software may come with sample files that may produce strange results when being used. To make all applications use /etc/hosts exclusively when looking up the IP-address of a host, you have to edit the /etc/host.conf file. Comment out any lines that begin with the keyword order by preceding them with a hash sign, and insert the line
order hostsThe configuration of the resolver library will be covered in detail in chapter-.
The hosts file contains one entry per line, consisting of an IP-address, a hostname, and an optional list of aliases for the hostname. The fields are separated by spaces or tabs, and the address field must begin in column one. Anything following a hash sign (#) is regarded as a comment and is ignored.
Hostnames can be either fully qualified, or relative to the local domain. For vale, you would usually enter the the fully qualified name, vale.vbrew.com, and vale by itself in the hosts file, so that it is known by both its official name and the shorter local name.
# # Hosts file for Virtual Brewery/Virtual Winery # # IP local fully qualified domain name # 127.0.0.1 localhost # 18.104.22.168 vlager vlager.vbrew.com 22.214.171.124 vlager-if1 126.96.36.199 vstout vstout.vbrew.com 188.8.131.52 vale vale.vbrew.com # 184.108.40.206 vlager-if2 220.127.116.11 vbeaujolais vbeaujolais.vbrew.com 18.104.22.168 vbardolino vbardolino.vbrew.com 22.214.171.124 vchianti vchianti.vbrew.comJust as with a host's IP-address, you sometimes would like to use a symbolic name for network numbers, too. Therefore, the hosts file has a companion called /etc/networks that maps network names to network numbers and vice versa. At the Virtual Brewery, we might install a networks file like this:
# /etc/networks for the Virtual Brewery brew-net 126.96.36.199 wine-net 188.8.131.52
Next: Interface Configuration for IP Up: Configuring TCP/IP Networking Previous: Assigning IP-Addresses Andrew Anderson
Thu Mar 7 23:22:06 EST 1996