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 | <para>If you don't have any network cards, you are most likely not going to
|
---|
9 | create any configuration files relating to network cards. If that is the
|
---|
10 | case, you must remove the <filename>network</filename> symlinks from all the
|
---|
11 | runlevel directories
|
---|
12 | (<filename class="directory">/etc/rc.d/rc*.d</filename>)</para>
|
---|
13 |
|
---|
14 | <sect2>
|
---|
15 | <title>Configuring default gateway</title>
|
---|
16 |
|
---|
17 | <para>If you're on a network you may need to set up the default gateway for
|
---|
18 | this machine. This is done by adding the proper values to the
|
---|
19 | /etc/sysconfig/network file by running the following:</para>
|
---|
20 |
|
---|
21 | <screen><userinput>cat >> /etc/sysconfig/network << "EOF"</userinput>
|
---|
22 | GATEWAY=192.168.1.2
|
---|
23 | GATEWAY_IF=eth0
|
---|
24 | <userinput>EOF</userinput></screen>
|
---|
25 |
|
---|
26 | <para>The values for GATEWAY and GATEWAY_IF need to be changed to match
|
---|
27 | your network setup. GATEWAY contains the IP address of the default
|
---|
28 | gateway, and GATEWAY_IF contains the network interface through which the
|
---|
29 | default gateway can be reached.</para>
|
---|
30 |
|
---|
31 | </sect2>
|
---|
32 |
|
---|
33 | <sect2>
|
---|
34 | <title>Creating network interface configuration files</title>
|
---|
35 |
|
---|
36 | <para>Which interfaces are brought up and down by the network script depends on
|
---|
37 | the files in the /etc/sysconfig/network-devices directory. This
|
---|
38 | directory should contain files in the form of ifconfig.xyz, where xyz is a
|
---|
39 | network interface name (such as eth0 or eth0:1)</para>
|
---|
40 |
|
---|
41 | <para>If you decide to rename or move this /etc/sysconfig/network-devices
|
---|
42 | directory, make sure you update the /etc/sysconfig/rc file as well and
|
---|
43 | update the network_devices by providing it with the new path.</para>
|
---|
44 |
|
---|
45 | <para>Now, new files are created in that directory containing the following.
|
---|
46 | The following command creates a sample ifconfig.eth0 file:</para>
|
---|
47 |
|
---|
48 | <screen><userinput>cat > /etc/sysconfig/network-devices/ifconfig.eth0 << "EOF"</userinput>
|
---|
49 | ONBOOT=yes
|
---|
50 | IP=192.168.1.1
|
---|
51 | NETMASK=255.255.255.0
|
---|
52 | BROADCAST=192.168.1.255
|
---|
53 | <userinput>EOF</userinput></screen>
|
---|
54 |
|
---|
55 | <para>Of course, the values of those variables have to be changed
|
---|
56 | in every file to match the proper setup. If the ONBOOT variable is set
|
---|
57 | to yes, the network script will bring it up during the booting of the system.
|
---|
58 | If set to anything else but yes, it will be ignored by the network script
|
---|
59 | and thus not brought up.</para>
|
---|
60 |
|
---|
61 | </sect2>
|
---|
62 |
|
---|
63 | <sect2>
|
---|
64 | <title>Creating the /etc/resolv.conf file</title>
|
---|
65 |
|
---|
66 | <para>If you're going to be connected to the internet then most likely you'll
|
---|
67 | need some means of DNS name resolution to resolve internet domain names to IP
|
---|
68 | addresses. This is best achieved by placing the IP address of a DNS server
|
---|
69 | into <filename>/etc/resolv.conf</filename>. Create the file by running the
|
---|
70 | following:</para>
|
---|
71 |
|
---|
72 | <screen><userinput>cat > /etc/resolv.conf << "EOF"</userinput>
|
---|
73 | # Begin /etc/resolv.conf
|
---|
74 |
|
---|
75 | nameserver <IP address of your nameserver>
|
---|
76 |
|
---|
77 | # End /etc/resolv.conf
|
---|
78 | <userinput>EOF</userinput></screen>
|
---|
79 |
|
---|
80 | <para>Of course, replace <IP address of your nameserver> with the IP
|
---|
81 | address of the DNS server most appropriate for your setup. This will often be
|
---|
82 | provided by your ISP or it may even be a router on your local network.</para>
|
---|
83 |
|
---|
84 | </sect2>
|
---|
85 |
|
---|
86 | </sect1>
|
---|
87 |
|
---|