1 | <sect1 id="ch07-hosts">
|
---|
2 | <title>Creating the /etc/hosts file</title>
|
---|
3 | <?dbhtml filename="hosts.html" dir="chapter07"?>
|
---|
4 |
|
---|
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
|
---|
7 | syntax is:</para>
|
---|
8 |
|
---|
9 | <para><screen><IP address> myhost.mydomain.org aliases</screen></para>
|
---|
10 |
|
---|
11 | <para>You should made sure that the IP-address is in the private network
|
---|
12 | IP-address range. Valid ranges are:</para>
|
---|
13 |
|
---|
14 | <para><screen> Class Networks
|
---|
15 | A 10.0.0.0
|
---|
16 | B 172.16.0.0 through 172.31.0.0
|
---|
17 | C 192.168.0.0 through 192.168.255.0</screen></para>
|
---|
18 |
|
---|
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>
|
---|
21 |
|
---|
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
|
---|
24 | correctly.</para>
|
---|
25 |
|
---|
26 | <para>If a network card is not going to be configured, create the
|
---|
27 | <filename>/etc/hosts</filename> file by running:</para>
|
---|
28 |
|
---|
29 | <para><screen><userinput>cat > /etc/hosts << "EOF"</userinput>
|
---|
30 | # Begin /etc/hosts (no network card version)
|
---|
31 |
|
---|
32 | 127.0.0.1 www.mydomain.com <value of HOSTNAME> localhost
|
---|
33 |
|
---|
34 | # End /etc/hosts (no network card version)
|
---|
35 | <userinput>EOF</userinput></screen></para>
|
---|
36 |
|
---|
37 | <para>If a network card is to be configured, create the
|
---|
38 | <filename>/etc/hosts</filename> file by running:</para>
|
---|
39 |
|
---|
40 | <para><screen><userinput>cat > /etc/hosts << "EOF"</userinput>
|
---|
41 | # Begin /etc/hosts (network card version)
|
---|
42 |
|
---|
43 | 127.0.0.1 localhost.localdomain localhost
|
---|
44 | 192.168.1.1 www.mydomain.org <value of HOSTNAME>
|
---|
45 |
|
---|
46 | # End /etc/hosts (network card version)
|
---|
47 | <userinput>EOF</userinput></screen></para>
|
---|
48 |
|
---|
49 | <para>Of course, the 192.168.1.1 and www.mydomain.org have to be changed
|
---|
50 | to your liking (or requirements if assigned an IP-address by a network/system
|
---|
51 | administrator and this machine is planned to be connected to an existing
|
---|
52 | network).</para>
|
---|
53 |
|
---|
54 | </sect1>
|
---|
55 |
|
---|