hosts.xml 2.8 KB

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