old-www/LDP/nag/node64.html

105 lines
4.6 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<!--Converted with LaTeX2HTML 96.1-c (Feb 29, 1996) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds -->
<HTML>
<HEAD>
<TITLE>Writing hosts and networks Files</TITLE>
</HEAD>
<BODY LANG="EN">
<A HREF="node1.html"><IMG WIDTH=65 HEIGHT=24 ALIGN=BOTTOM ALT="contents" SRC="contents_motif.gif"></A> <BR>
<B> Next:</B> <A HREF="node65.html">Interface Configuration for IP</A>
<B>Up:</B> <A HREF="node58.html">Configuring TCP/IP Networking</A>
<B> Previous:</B> <A HREF="node63.html">Assigning IP-Addresses</A>
<BR> <P>
<H1><A NAME="SECTION007600000">Writing hosts and networks Files</A></H1>
After you have sub-netted your network, you should prepare for some simple
sort of hostname resolution using the /etc/hosts file. If you are
not going to use DNS or NIS for address resolution, you have to put all
hosts in the hosts file.
<P>
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.<A HREF="footnode.html#3165"><IMG ALIGN=BOTTOM ALT="gif" SRC="foot_motif.gif"></A>
<P>
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
<Pre>
order hosts
</Pre>
The configuration of the resolver library will be covered in detail
in chapter-<A HREF="node80.html#resolv"><IMG ALIGN=BOTTOM ALT="gif" SRC="cross_ref_motif.gif"></A>.
<P>
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.
<P>
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.
<P>
This is an example how a hosts file at the Virtual Brewery
might look. Two special names are included, vlager-if1 and
vlager-if2 that give the addresses for both interfaces used
on vlager.
<a name="interfacefigsubnet"></a>
<pre>
#
# Hosts file for Virtual Brewery/Virtual Winery
#
# IP local fully qualified domain name
#
127.0.0.1 localhost
#
191.72.1.1 vlager vlager.vbrew.com
191.72.1.1 vlager-if1
191.72.1.2 vstout vstout.vbrew.com
191.72.1.3 vale vale.vbrew.com
#
191.72.2.1 vlager-if2
191.72.2.2 vbeaujolais vbeaujolais.vbrew.com
191.72.2.3 vbardolino vbardolino.vbrew.com
191.72.2.4 vchianti vchianti.vbrew.com
</pre>
Just 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:<A HREF="footnode.html#3166"><IMG ALIGN=BOTTOM ALT="gif" SRC="foot_motif.gif"></A>
<Pre>
# /etc/networks for the Virtual Brewery
brew-net 191.72.1.0
wine-net 191.72.2.0
</pre>
<HR><A HREF="node1.html"><IMG WIDTH=65 HEIGHT=24 ALIGN=BOTTOM ALT="contents" SRC="contents_motif.gif"></A> <BR>
<B> Next:</B> <A HREF="node65.html">Interface Configuration for IP</A>
<B>Up:</B> <A HREF="node58.html">Configuring TCP/IP Networking</A>
<B> Previous:</B> <A HREF="node63.html">Assigning IP-Addresses</A>
<P><ADDRESS>
<I>Andrew Anderson <BR>
Thu Mar 7 23:22:06 EST 1996</I>
</ADDRESS>
</BODY>
</HTML>