1 | <sect1 id="ch07-hosts">
|
---|
2 | <title>Creating the /etc/hosts file</title>
|
---|
3 |
|
---|
4 | <para>If a network card is to be configured, you have to decide on the
|
---|
5 | IP-address, FQDN and possible aliases for use in the /etc/hosts file. An
|
---|
6 | example is:</para>
|
---|
7 |
|
---|
8 | <para><screen><my-IP> myhost.mydomain.org aliases</screen></para>
|
---|
9 |
|
---|
10 | <para>You should made sure that the IP-address is in the private network
|
---|
11 | IP-address range. Valid ranges are:</para>
|
---|
12 |
|
---|
13 | <para><screen> Class Networks
|
---|
14 | A 10.0.0.0
|
---|
15 | B 172.16.0.0 through 172.31.0.0
|
---|
16 | C 192.168.0.0 through 192.168.255.0</screen></para>
|
---|
17 |
|
---|
18 | <para>A valid IP address could be 192.168.1.1. A valid FQDN for this IP could
|
---|
19 | be www.linuxfromscratch.org</para>
|
---|
20 |
|
---|
21 | <para>If you aren't going to use a network card, you still need to
|
---|
22 | come up with a FQDN. This is necessary for programs like Sendmail to operate
|
---|
23 | correctly (in fact; Sendmail won't run when it can't determine the FQDN).</para>
|
---|
24 |
|
---|
25 | <para>If a network card is not going to be configured, a new file
|
---|
26 | <filename>/etc/hosts</filename> is created by running:</para>
|
---|
27 |
|
---|
28 | <para><screen><userinput>cat > /etc/hosts << "EOF"</userinput>
|
---|
29 | # Begin /etc/hosts (no network card version)
|
---|
30 |
|
---|
31 | 127.0.0.1 www.mydomain.com <value of HOSTNAME> localhost
|
---|
32 |
|
---|
33 | # End /etc/hosts (no network card version)
|
---|
34 | <userinput>EOF</userinput></screen></para>
|
---|
35 |
|
---|
36 | <para>If a network card is to be configured, a new file
|
---|
37 | <filename>/etc/hosts</filename> is created by running:</para>
|
---|
38 |
|
---|
39 | <para><screen><userinput>cat > /etc/hosts << "EOF"</userinput>
|
---|
40 | # Begin /etc/hosts (network card version)
|
---|
41 |
|
---|
42 | 127.0.0.1 localhost.localdomain localhost
|
---|
43 | 192.168.1.1 www.mydomain.org <value of HOSTNAME>
|
---|
44 |
|
---|
45 | # End /etc/hosts (network card version)
|
---|
46 | <userinput>EOF</userinput></screen></para>
|
---|
47 |
|
---|
48 | <para>Of course, the 192.168.1.1 and www.mydomain.org have to be changed
|
---|
49 | to your liking (or requirements if assigned an IP-address by a network/system
|
---|
50 | administrator and this machine is planned to be connected to that
|
---|
51 | network).</para>
|
---|
52 |
|
---|
53 | </sect1>
|
---|
54 |
|
---|