hosts.xml 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <sect1 id="ch07-hosts">
  2. <title>Creating the /etc/hosts file</title>
  3. <para>
  4. If a network card is to be configured, a user has to decide on the
  5. IP-address, FQDN and possible aliases for use in the /etc/hosts file. An
  6. example is:
  7. </para>
  8. <para>
  9. <screen>
  10. &lt;my-IP&gt; myhost.mydomain.org aliases
  11. </screen>
  12. </para>
  13. <para>
  14. It should made sure that the IP-address is in the private network
  15. IP-address range. Valid ranges are:
  16. </para>
  17. <para>
  18. <screen>
  19. Class Networks
  20. A 10.0.0.0
  21. B 172.16.0.0 through 172.31.0.0
  22. C 192.168.0.0 through 192.168.255.0
  23. </screen>
  24. </para>
  25. <para>
  26. A valid IP address could be 192.168.1.1. A valid FQDN for this IP could
  27. be www.linuxfromscratch.org
  28. </para>
  29. <para>
  30. If a user is not going to use a network card, he still needs to come up with a
  31. FQDN. This is necessary for programs like Sendmail to operate correctly (in
  32. fact; Sendmail won't run when it can't determine the FQDN).
  33. </para>
  34. <para>
  35. If a network card is not going to be configured, a new file
  36. <filename>/etc/hosts</filename> is created by running:
  37. </para>
  38. <para>
  39. <screen>
  40. <userinput>cat &gt; /etc/hosts &lt;&lt; "EOF"</userinput>
  41. # Begin /etc/hosts (no network card version)
  42. 127.0.0.1 www.mydomain.com &lt;value of HOSTNAME&gt; localhost
  43. # End /etc/hosts (no network card version)
  44. <userinput>EOF</userinput>
  45. </screen>
  46. </para>
  47. <para>
  48. If a network card is to be configured, a new file
  49. <filename>/etc/hosts</filename> is created containing:
  50. </para>
  51. <para>
  52. <screen>
  53. <userinput>cat &gt; /etc/hosts &lt;&lt; "EOF"</userinput>
  54. # Begin /etc/hosts (network card version)
  55. 127.0.0.1 localhost.localdomain localhost
  56. 192.168.1.1 www.mydomain.org &lt;value of HOSTNAME&gt;
  57. # End /etc/hosts (network card version)
  58. <userinput>EOF</userinput>
  59. </screen>
  60. </para>
  61. <para>
  62. Of course, the 192.168.1.1 and www.mydomain.org have to be changed to the
  63. users
  64. liking (or requirements if assigned an IP-address by a network/system
  65. administrator and this machine is planned to be connected to that network).
  66. </para>
  67. </sect1>