[e0f737f] | 1 | <sect1 id="ch07-hosts">
|
---|
[b08f409] | 2 | <title>Creating the /etc/hosts file</title>
|
---|
| 3 |
|
---|
[fa914e5] | 4 | <para>If a network card is to be configured, you have 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 |
|
---|
[fa914e5] | 10 | <para>You should made sure that the IP-address is in the private network
|
---|
[b822811] | 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 |
|
---|
[fa914e5] | 21 | <para>If you aren't going to use a network card, you still need to
|
---|
[b822811] | 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 |
|
---|
[fa914e5] | 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>
|
---|
[b08f409] | 52 |
|
---|
| 53 | </sect1>
|
---|
| 54 |
|
---|