hosts.xml 2.9 KB

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