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