[673b0d8] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
[d781ffb] | 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
|
---|
| 3 | "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
|
---|
[673b0d8] | 4 | <!ENTITY % general-entities SYSTEM "../general.ent">
|
---|
| 5 | %general-entities;
|
---|
| 6 | ]>
|
---|
[d781ffb] | 7 |
|
---|
[3be4d97] | 8 | <sect1 id="ch-scripts-hosts">
|
---|
[d781ffb] | 9 | <?dbhtml filename="hosts.html"?>
|
---|
| 10 |
|
---|
[f76cde8] | 11 | <title>Customizing the /etc/hosts File</title>
|
---|
[673b0d8] | 12 |
|
---|
[d781ffb] | 13 | <indexterm zone="ch-scripts-hosts">
|
---|
| 14 | <primary sortas="e-/etc/hosts">/etc/hosts</primary>
|
---|
| 15 | </indexterm>
|
---|
[81fd230] | 16 |
|
---|
[d781ffb] | 17 | <indexterm zone="ch-scripts-hosts">
|
---|
| 18 | <primary sortas="d-localnet">localnet</primary>
|
---|
| 19 | <secondary>/etc/hosts</secondary></indexterm>
|
---|
[81fd230] | 20 |
|
---|
[d781ffb] | 21 | <indexterm zone="ch-scripts-hosts">
|
---|
| 22 | <primary sortas="d-network">network</primary>
|
---|
| 23 | <secondary>/etc/hosts</secondary></indexterm>
|
---|
[81fd230] | 24 |
|
---|
[d781ffb] | 25 | <para>If a network card is to be configured, decide on the IP address,
|
---|
| 26 | FQDN, and possible aliases for use in the
|
---|
| 27 | <filename>/etc/hosts</filename> file. The syntax is:</para>
|
---|
[81fd230] | 28 |
|
---|
[d781ffb] | 29 | <screen><literal><IP address> myhost.example.org aliases</literal></screen>
|
---|
[81fd230] | 30 |
|
---|
[d781ffb] | 31 | <para>Unless the computer is to be visible to the Internet (i.e.,
|
---|
| 32 | there is a registered domain and a valid block of assigned IP
|
---|
| 33 | addresses—most users do not have this), make sure that the IP
|
---|
| 34 | address is in the private network IP address range. Valid ranges
|
---|
| 35 | are:</para>
|
---|
[81fd230] | 36 |
|
---|
[d781ffb] | 37 | <screen><literal> Class Networks
|
---|
[81fd230] | 38 | A 10.0.0.0
|
---|
[eb7bcc4] | 39 | B 172.16.0.0 through 172.31.0.255
|
---|
[d781ffb] | 40 | C 192.168.0.0 through 192.168.255.255</literal></screen>
|
---|
[81fd230] | 41 |
|
---|
[d781ffb] | 42 | <para>A valid IP address could be 192.168.1.1. A valid FQDN for this
|
---|
| 43 | IP could be www.linuxfromscratch.org (not recommended because this is
|
---|
| 44 | a valid registered domain address and could cause domain name server
|
---|
| 45 | issues).</para>
|
---|
[81fd230] | 46 |
|
---|
[d781ffb] | 47 | <para>Even if not using a network card, an FQDN is still required.
|
---|
| 48 | This is necessary for certain programs to operate correctly.</para>
|
---|
[81fd230] | 49 |
|
---|
[d781ffb] | 50 | <para>Create the <filename>/etc/hosts</filename> file by running:</para>
|
---|
[b822811] | 51 |
|
---|
[f67f5cf] | 52 | <screen><userinput>cat > /etc/hosts << "EOF"
|
---|
[d72e04a] | 53 | <literal># Begin /etc/hosts (network card version)
|
---|
[b08f409] | 54 |
|
---|
[d72e04a] | 55 | 127.0.0.1 localhost
|
---|
| 56 | <replaceable>[192.168.1.1]</replaceable> <replaceable>[<HOSTNAME>.example.org]</replaceable> <replaceable>[HOSTNAME]</replaceable>
|
---|
[b08f409] | 57 |
|
---|
[d72e04a] | 58 | # End /etc/hosts (network card version)</literal>
|
---|
[f67f5cf] | 59 | EOF</userinput></screen>
|
---|
[b822811] | 60 |
|
---|
[d781ffb] | 61 | <para>The <replaceable>[192.168.1.1]</replaceable> and
|
---|
| 62 | <replaceable>[<HOSTNAME>.example.org]</replaceable>
|
---|
| 63 | values need to be changed for specific users or requirements (if
|
---|
| 64 | assigned an IP address by a network/system administrator and the
|
---|
| 65 | machine will be connected to an existing network).</para>
|
---|
[81fd230] | 66 |
|
---|
[d781ffb] | 67 | <para>If a network card is not going to be configured, create the
|
---|
| 68 | <filename>/etc/hosts</filename> file by running:</para>
|
---|
[b822811] | 69 |
|
---|
[0ebe9fa4] | 70 | <screen role="nodump"><userinput>cat > /etc/hosts << "EOF"
|
---|
[d72e04a] | 71 | <literal># Begin /etc/hosts (no network card version)
|
---|
[b08f409] | 72 |
|
---|
[d72e04a] | 73 | 127.0.0.1 <replaceable>[<HOSTNAME>.example.org]</replaceable> <replaceable>[HOSTNAME]</replaceable> localhost
|
---|
[b08f409] | 74 |
|
---|
[d72e04a] | 75 | # End /etc/hosts (no network card version)</literal>
|
---|
[f67f5cf] | 76 | EOF</userinput></screen>
|
---|
[b08f409] | 77 |
|
---|
| 78 | </sect1>
|
---|