[b08f409] | 1 | <sect1 id="ch09-hosts">
|
---|
| 2 | <title>Creating the /etc/hosts file</title>
|
---|
| 3 |
|
---|
| 4 | <para>
|
---|
| 5 | If you want to configure a network card, you have 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 | Make sure the IP-address is in the private network IP-address range.
|
---|
| 18 | 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 you're not going to use a network card, you still need 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 you don't configure a network card, create a new file
|
---|
| 43 | <filename>/etc/hosts</filename> 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 you do configure a network card, create a new file
|
---|
| 60 | <filename>/etc/hosts</filename> 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, change the 192.168.1.1 and www.mydomain.org to your own
|
---|
| 78 | liking (or requirements if you are assigned an IP-address by a network/system
|
---|
| 79 | administrator and you plan on connecting this machine to that network).
|
---|
| 80 | </para>
|
---|
| 81 |
|
---|
| 82 | </sect1>
|
---|
| 83 |
|
---|