1 <sect1 id="ch-scripts-hosts">
2 <title>Creating the /etc/hosts file</title>
3 <?dbhtml filename="hosts.html" dir="chapter07"?>
5 <para>If a network card is to be configured, you have to decide on the
6 IP-address, FQDN and possible aliases for use in the /etc/hosts file. The
9 <screen><IP address> myhost.example.org aliases</screen>
11 <para>You should make sure that the IP-address is in the private network
12 IP-address range. Valid ranges are:</para>
14 <screen> Class Networks
16 B 172.16.0.0 through 172.31.0.0
17 C 192.168.0.0 through 192.168.255.0</screen>
19 <para>A valid IP address could be 192.168.1.1. A valid FQDN for this IP could
20 be www.linuxfromscratch.org.</para>
22 <para>If you aren't going to use a network card, you still need to
23 come up with a FQDN. This is necessary for certain programs to operate
26 <para>If a network card is not going to be configured, create the
27 <filename>/etc/hosts</filename> file by running:</para>
29 <screen><userinput>cat > /etc/hosts << "EOF"</userinput>
30 # Begin /etc/hosts (no network card version)
32 127.0.0.1 <value of HOSTNAME>.example.org <value of HOSTNAME> localhost
34 # End /etc/hosts (no network card version)
35 <userinput>EOF</userinput></screen>
37 <para>If a network card is to be configured, create the
38 <filename>/etc/hosts</filename> file by running:</para>
40 <screen><userinput>cat > /etc/hosts << "EOF"</userinput>
41 # Begin /etc/hosts (network card version)
44 192.168.1.1 <value of HOSTNAME>.example.org <value of HOSTNAME>
46 # End /etc/hosts (network card version)
47 <userinput>EOF</userinput></screen>
49 <para>Of course, the 192.168.1.1 and <value of HOSTNAME>.example.org
50 have to be changed to your liking (or requirements if assigned an IP-address
51 by a network/system administrator and this machine is planned to be connected
52 to an existing network).</para>