network.xml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.5/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>General Network Configuration</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. <sect2>
  16. <title>Creating Network Interface Configuration Files</title>
  17. <para>Which interfaces are brought up and down by the network script
  18. depends on the files in <filename
  19. class="directory">/etc/sysconfig/</filename>. This directory should
  20. contain a file for each interface to be configured, such as
  21. <filename>ifconfig.xyz</filename>, where <quote>xyz</quote> is
  22. meaningful to the administrator such as the device name (e.g. eth0).
  23. Inside this file are attributes to this interface, such as its IP
  24. address(es), subnet masks, and so forth. It is necessary that
  25. the stem of the filename be <emphasis>ifconfig</emphasis>.</para>
  26. <para>The following command creates a sample file for the
  27. <emphasis>eth0</emphasis> device with a static IP address:</para>
  28. <screen><userinput>cd /etc/sysconfig/
  29. cat &gt; ifconfig.eth0 &lt;&lt; "EOF"
  30. <literal>ONBOOT=yes
  31. IFACE=eth0
  32. SERVICE=ipv4-static
  33. IP=192.168.1.1
  34. GATEWAY=192.168.1.2
  35. PREFIX=24
  36. BROADCAST=192.168.1.255</literal>
  37. EOF</userinput></screen>
  38. <para>The values of these variables must be changed in every file to match
  39. the proper setup.</para>
  40. <para>If the <envar>ONBOOT</envar> variable is set to <quote>yes</quote> the
  41. network script will bring up the Network Interface Card (NIC) during
  42. booting of the system. If set to anything but <quote>yes</quote> the NIC
  43. will be ignored by the network script and not be automatically brought up.
  44. The interface can be manually started or stopped with the
  45. <command>ifup</command> and <command>ifdown</command> commands.</para>
  46. <para>The <envar>IFACE</envar> variable defines the interface name,
  47. for example, eth0. It is required for all network device configuration
  48. files. </para>
  49. <para>The <envar>SERVICE</envar> variable defines the method used for
  50. obtaining the IP address. The LFS-Bootscripts package has a modular IP
  51. assignment format, and creating additional files in the <filename
  52. class="directory">/lib/services/</filename> directory allows other IP
  53. assignment methods. This is commonly used for Dynamic Host Configuration
  54. Protocol (DHCP), which is addressed in the 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 contains 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.
  66. If omitted, the PREFIX defaults to 24.</para>
  67. <para>For more information see the <command>ifup</command> man page.</para>
  68. </sect2>
  69. <sect2 id="resolv.conf">
  70. <title>Creating the /etc/resolv.conf File</title>
  71. <indexterm zone="resolv.conf">
  72. <primary sortas="e-/etc/resolv.conf">/etc/resolv.conf</primary>
  73. </indexterm>
  74. <para>If the system is going to be connected to the Internet, it will
  75. need some means of Domain Name Service (DNS) name resolution to
  76. resolve Internet domain names to IP addresses, and vice versa. This is
  77. best achieved by placing the IP address of the DNS server, available
  78. from the ISP or network administrator, into
  79. <filename>/etc/resolv.conf</filename>. Create the file by running the
  80. following:</para>
  81. <screen><userinput>cat &gt; /etc/resolv.conf &lt;&lt; "EOF"
  82. <literal># Begin /etc/resolv.conf
  83. domain <replaceable>&lt;Your Domain Name&gt;</replaceable>
  84. nameserver <replaceable>&lt;IP address of your primary nameserver&gt;</replaceable>
  85. nameserver <replaceable>&lt;IP address of your secondary nameserver&gt;</replaceable>
  86. # End /etc/resolv.conf</literal>
  87. EOF</userinput></screen>
  88. <para>The <varname>domain</varname> statement can be omitted
  89. or replaced with a <varname>search</varname> statement. See the man page for
  90. resolv.conf for more details.</para>
  91. <para>Replace <replaceable>&lt;IP address of the nameserver&gt;</replaceable>
  92. with the IP address of the DNS most appropriate for the setup. There will
  93. often be more than one entry (requirements demand secondary servers for
  94. fallback capability). If you only need or want one DNS server, remove the
  95. second <emphasis>nameserver</emphasis> line from the file. The IP address
  96. may also be a router on the local network.</para>
  97. <note><para>The Google Public IPv4 DNS addresses are 8.8.8.8 and 8.8.4.4.</para></note>
  98. </sect2>
  99. </sect1>