network.xml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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-network">
  8. <?dbhtml filename="network.html"?>
  9. <title>Configuring the network Script</title>
  10. <indexterm zone="ch-scripts-network">
  11. <primary sortas="d-network">network</primary>
  12. <secondary>configuring</secondary></indexterm>
  13. <para>This section only applies if a network card is to be
  14. configured.</para>
  15. <para>If a network card will not be used, there is likely no need to
  16. create any configuration files relating to network cards. If that is
  17. the case, remove the <filename class="symlink">network</filename>
  18. symlinks from all run-level directories (<filename
  19. class="directory">/etc/rc.d/rc*.d</filename>).</para>
  20. <sect2>
  21. <title>Creating Network Interface Configuration Files</title>
  22. <para>Which interfaces are brought up and down by the network script
  23. depends on the files and directories in the <filename
  24. class="directory">/etc/sysconfig/network-devices</filename> hierarchy.
  25. This directory should contain a sub-directory for each interface to be
  26. configured, such as <filename>ifconfig.xyz</filename>, where
  27. <quote>xyz</quote> is a network interface name. Inside this directory
  28. would be files defining the attributes to this interface, such as its IP
  29. address(es), subnet masks, and so forth.</para>
  30. <para>The following command creates a sample <filename>ipv4</filename>
  31. file for the <emphasis>eth0</emphasis> device:</para>
  32. <screen><userinput>cd /etc/sysconfig/network-devices &amp;&amp;
  33. mkdir -v ifconfig.eth0 &amp;&amp;
  34. cat &gt; ifconfig.eth0/ipv4 &lt;&lt; "EOF"
  35. <literal>ONBOOT=yes
  36. SERVICE=ipv4-static
  37. IP=192.168.1.1
  38. GATEWAY=192.168.1.2
  39. PREFIX=24
  40. BROADCAST=192.168.1.255</literal>
  41. EOF</userinput></screen>
  42. <para>The values of these variables must be changed in every file to match
  43. the proper setup. If the <envar>ONBOOT</envar> variable is set to
  44. <quote>yes</quote> the network script will bring up the Network Interface
  45. Card (NIC) during booting of the system. If set to anything but
  46. <quote>yes</quote> the NIC will be ignored by the network script and not
  47. be brought up.</para>
  48. <para>The <envar>SERVICE</envar> variable defines the method used for
  49. obtaining the IP address. The LFS-Bootscripts package has a modular IP
  50. assignment format, and creating additional files in the <filename
  51. class="directory">/etc/sysconfig/network-devices/services</filename>
  52. directory allows other IP assignment methods. This is commonly used for
  53. Dynamic Host Configuration Protocol (DHCP), which is addressed in the
  54. BLFS book.</para>
  55. <para>The <envar>GATEWAY</envar> variable should contain the default
  56. gateway IP address, if one is present. If not, then comment out the
  57. variable entirely.</para>
  58. <para>The <envar>PREFIX</envar> variable needs to contain the number of
  59. bits used in the subnet. Each octet in an IP address is 8 bits. If the
  60. subnet's netmask is 255.255.255.0, then it is using the first three octets
  61. (24 bits) to specify the network number. If the netmask is 255.255.255.240,
  62. it would be using the first 28 bits. Prefixes longer than 24 bits are
  63. commonly used by DSL and cable-based Internet Service Providers (ISPs).
  64. In this example (PREFIX=24), the netmask is 255.255.255.0. Adjust the
  65. <envar>PREFIX</envar> variable according to your specific subnet.</para>
  66. </sect2>
  67. <sect2 id="resolv.conf">
  68. <title>Creating the /etc/resolv.conf File</title>
  69. <indexterm zone="resolv.conf">
  70. <primary sortas="e-/etc/resolv.conf">/etc/resolv.conf</primary>
  71. </indexterm>
  72. <para>If the system is going to be connected to the Internet, it will
  73. need some means of Domain Name Service (DNS) name resolution to
  74. resolve Internet domain names to IP addresses, and vice versa. This is
  75. best achieved by placing the IP address of the DNS server, available
  76. from the ISP or network administrator, into
  77. <filename>/etc/resolv.conf</filename>. Create the file by running the
  78. following:</para>
  79. <screen><userinput>cat &gt; /etc/resolv.conf &lt;&lt; "EOF"
  80. <literal># Begin /etc/resolv.conf
  81. domain {<replaceable>[Your Domain Name]</replaceable>}
  82. nameserver <replaceable>[IP address of your primary nameserver]</replaceable>
  83. nameserver <replaceable>[IP address of your secondary nameserver]</replaceable>
  84. # End /etc/resolv.conf</literal>
  85. EOF</userinput></screen>
  86. <para>Replace <replaceable>[IP address of the nameserver]</replaceable>
  87. with the IP address of the DNS most appropriate for the setup. There will
  88. often be more than one entry (requirements demand secondary servers for
  89. fallback capability). If you only need or want one DNS server, remove the
  90. second <emphasis>nameserver</emphasis> line from the file. The IP address
  91. may also be a router on the local network.</para>
  92. </sect2>
  93. </sect1>