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