[e0f737f] | 1 | <sect1 id="ch07-hosts">
|
---|
[b08f409] | 2 | <title>Creating the /etc/hosts file</title>
|
---|
| 3 |
|
---|
[b822811] | 4 | <para>If a network card is to be configured, a user has to decide on the
|
---|
[b08f409] | 5 | IP-address, FQDN and possible aliases for use in the /etc/hosts file. An
|
---|
[b822811] | 6 | example is:</para>
|
---|
| 7 |
|
---|
| 8 | <para><screen><my-IP> myhost.mydomain.org aliases</screen></para>
|
---|
| 9 |
|
---|
| 10 | <para>It 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
|
---|
[b08f409] | 14 | A 10.0.0.0
|
---|
| 15 | B 172.16.0.0 through 172.31.0.0
|
---|
[b822811] | 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 a user is not going to use a network card, he still needs 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>
|
---|
[b08f409] | 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)
|
---|
[b822811] | 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>
|
---|
[b08f409] | 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)
|
---|
[b822811] | 46 | <userinput>EOF</userinput></screen></para>
|
---|
[b08f409] | 47 |
|
---|
[b822811] | 48 | <para>Of course, the 192.168.1.1 and www.mydomain.org have to be changed to the
|
---|
[137bd50] | 49 | users
|
---|
| 50 | liking (or requirements if assigned an IP-address by a network/system
|
---|
[b822811] | 51 | administrator and this machine is planned to be
|
---|
| 52 | connected to that network).</para>
|
---|
[b08f409] | 53 |
|
---|
| 54 | </sect1>
|
---|
| 55 |
|
---|