network.xml 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <sect1 id="ch07-network">
  2. <title>Configuring the network script</title>
  3. <?dbhtml filename="network.html" dir="chapter07"?>
  4. <para>This section only applies if you're going to configure a network
  5. card.</para>
  6. <sect2>
  7. <title>Configuring default gateway</title>
  8. <para>If you're on a network you may need to setup the default gateway for
  9. this machine. This is done by adding the proper values to the
  10. /etc/sysconfig/network file by running the following:</para>
  11. <para><screen><userinput>cat &gt;&gt; /etc/sysconfig/network &lt;&lt; "EOF"</userinput>
  12. GATEWAY=192.168.1.2
  13. GATEWAY_IF=eth0
  14. <userinput>EOF</userinput></screen></para>
  15. <para>The values for GATEWAY and GATEWAY_IF need to be changed to match
  16. your network setup. GATEWAY contains the IP address of the default
  17. gateway, and GATEWAY_IF contains the network interface through which the
  18. default gateway can be reached.</para>
  19. </sect2>
  20. <sect2>
  21. <title>Creating network interface configuration files</title>
  22. <para>Which interfaces are brought up and down by the network script depends on
  23. the files in the /etc/sysconfig/network-devices directory. This
  24. directory should contain files in the form of ifconfig.xyz, where xyz is a
  25. network interface name (such as eth0 or eth0:1)</para>
  26. <para>First let's create this directory by running:</para>
  27. <para><screen><userinput>mkdir /etc/sysconfig/network-devices</userinput></screen></para>
  28. <para>We also need to add this directory path to the /etc/sysconfig/rc file
  29. so that other scripts (like ifup and ifdown) know where this directory is
  30. located.</para>
  31. <para>Update the /etc/sysconfig/rc file by running:</para>
  32. <para><screen><userinput>echo "network_devices=/etc/sysconfig/network-devices" >> /etc/sysconfig/rc</userinput></screen></para>
  33. <para>Now, new files are created in that directory containing the following.
  34. The following command creates a sample ifconfig.eth0 file:</para>
  35. <para><screen><userinput>cat &gt; /etc/sysconfig/network-devices/ifconfig.eth0 &lt;&lt; "EOF"</userinput>
  36. ONBOOT=yes
  37. DEVICE=eth0
  38. IP=192.168.1.1
  39. NETMASK=255.255.255.0
  40. BROADCAST=192.168.1.255
  41. <userinput>EOF</userinput></screen></para>
  42. <para>Of course, the values of those variables have to be changed
  43. in every file to match the proper setup. Usually NETMASK and BROADCAST
  44. will remain the same, just the DEVICE and IP variables will change per
  45. network interface. If the ONBOOT variable is set to yes, the network script
  46. will bring it up during boot up of the system. If set to anything else but
  47. yes it will be ignored by the network script and thus not brought up.</para>
  48. </sect2>
  49. </sect1>