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