Network Configuration
◾
495
ifup-ipv6,
ifup-ppp, ifup-routes, and init.ipv6-global. The ifup scripts start the various
device interfaces, obtain IPv4 and IPv6 addresses, and establish data to be placed into the
ifcfg configuration files (e.g., ifcfg-eth0 and ifcfg-lo).
12.3.2 The /etc/sysconfig/network-scripts Directory’s Contents
Let us explore the /etc/sysconfig/network-scripts directory in a little more detail. The list-
ing is shown in Figure 12.3. There are four types of files here. First, there are two data files:
ifcfg-eth0
and
ifcfg-lo
. These files contain configuration information about this
computer’s two interface devices, eth0 and lo. Next, there are several executable scripts.
These
are all named
ifdown-
device
and
ifup-
device
as in
ifdown-eth
and
ifup-
ippp
. There are two such scripts,
ifdown-isdn
and
ifup-isdn
, which are actually sym-
bolic links to
ifdown-ippp
and
ifup-ippp,
respectively. The files
ifdown
and
ifup
are also symbolic links, but in this case to services located in
/sbin
:
/sbin/ifdown
and
/sbin/ifup
. Finally, the files
network-functions
and
network-functions-ipv6
are script files containing network script functions, as mentioned earlier.
Most of the scripts in this directory are of the form
ifdown
or
ifup
. As you might
expect,
ifdown
is used to bring
an interface down while
ifup
is used to start an inter-
face. The scripts ifdown and ifup expect an interface as an argument as in
ifdown eth0
.
The remainder of these scripts are named after specific interfaces, so that, for instance,
ifdown eth0
and
ifdown-eth
will accomplish the same thing. The interfaces covered
by these scripts are bnep, eth, ippp, ipv6, isdn, post, ppp, routes, sit, and tunnel. The ifup
version also includes scripts for aliases, plip, plusb, and wireless.
We will not explore the
content of these
ifup
and
ifdown
scripts as they are very involved. If you are interested
in studying these devices, you should explore a text on Linux networking.
Let us instead focus on one of the two configuration files,
ifcfg-eth0
. You will have
a configuration file for each network interface device. In the computer illustrated in Figure
12.3, there are only two interface devices, eth0 and lo. The ifcfg-eth0 file contains a listing
of a number of environment variables as used by the networking services.
These values are
established at the time the network is brought up (or when ifup-eth0 is called upon to bring
up the Ethernet device).
Some of the most important variables and their content are shown in Table 12.3 along
with the meaning and range of values permissible. Of particular note are BOOTPROTO,
BROADCAST, GATEWAY, HWADDR, and ONBOOT. These five values specify the
mechanism by which this device will be given an IP address (statically assigned, assigned
by DHCP, or none), the IP address of this device’s broadcast device, the IP address of this
FIGURE 12.3
Contents of the network-scripts directory.
496
◾
Linux with Operating System Concepts
device’s gateway device, the MAC address of this device, and whether
the device should be
started upon boot.
Notice that BROADCAST and GATEWAY are IP addresses of the network/subnet-
work’s broadcast device and gateway device, respectively. These variables are typically
not assigned if BOOTPROTO is dhcp. If BOOTPROTO is static, you should have one but
not necessarily both values assigned. Also, if BOOTPROTO is dhcp, you would not have
an entry for IPADDR; instead, this is filled in only if you want to statically assign an IP
address to your interface.
Let us consider the role of the value NETMASK. A broadcast
device may need to deter-
mine a network address from an IP address. This is performed by ANDing the IP address
to the network’s netmask. Thus, we store this value in the variable NETMASK. Let us look
at a couple of examples.
If the netmask is 255.255.240.0 and the IP address is 10.11.12.13, then we obtain the local
network’s address as 255.255.240.0 AND 10.11.12.13. First, we have to convert these two
sets of octets from decimal to binary.
255.255.192.0
=
11111111.11111111.11110000.00000000
10.11.12.13
=
00001010.00001011.00001100.00001101
TABLE 12.3
Contents of eth0 Configuration File
Do'stlaringiz bilan baham: