Official Red Hat Linux Administrators Guide

Interface configuration files control the operation of individual network interface devices. As your Red Hat Linux system boots, it uses these files to determine what interfaces to bring up and how to configure them. These files are usually named ifcfg-name, where name refers to the name of the device that the configuration file controls.

Ethernet Interfaces

One of the most common interface files is ifcfg-eth0, which controls the first network interface card, or NIC, in the system. A system with multiple NICs will also have multiple ifcfg-eth files, each one having a unique number at the end of the file name. Because each device has its own configuration file, you can control how each individual interface functions.

Following is a sample ifcfg-eth0 file for a system using a fixed IP address:

DEVICE=eth0 BOOTPROTO=none ONBOOT=yes NETWORK=10.0.1.0 NETMASK=255.255.255.0 IPADDR=10.0.1.27 USERCTL=no

The values required in an interface configuration file can change based on other values. For example, the ifcfg-eth0 file for an interface using DHCP looks quite a bit different from that for a system using a fixed IP address, because IP information is provided by the DHCP server:

DEVICE=eth0 BOOTPROTO=dhcp ONBOOT=yes

Most of the time you will probably want to use a GUI utility, such as the Network Administration Tool (redhat-config-network), to make changes to the various interface configuration files.

You can also edit the configuration file for a given network interface manually. Following is a listing of the parameters one can expect to configure in an interface configuration file. Within each of the interface configuration files, the following values are common:

Dial-up Interfaces

If you connect to the Internet via PPP dial-up connection, you need a configuration file for that interface as well. This file is created automatically for you when you use wvdial, the Network Administration Tool, or Kppp to create a dial-up account. In addition, any changes to dial-up account settings are reflected in these interface configuration files. The Official Red Hat Linux User’s Guide (Red Hat Press/Wiley, 2003) contains instructions for using these GUI-based dial-up connection tools. You can also create and edit this file manually.

A typical ifcfg-ppp0 file looks like this:

DEVICE=ppp0 NAME=test WVDIALSECT=test MODEMPORT=/dev/modem LINESPEED=115200 PAPNAME=test USERCTL=true ONBOOT=no PERSIST=no DEFROUTE=yes PEERDNS=yes DEMAND=no IDLETIMEOUT=600

Serial Line Internet Protocol (SLIP) is another dial-up interface, although it is less commonly used. SLIP files have interface configuration file names such as ifcfg-sl0. Among the options not already discussed that may be used in these files are the following:

Other Interfaces

Other common interface configuration files that use these options include ifcfg-lo, which controls the IP protocol’s local loopback device; ifcfg-irlan0, which arranges settings for the first infrared device; ifcfg-plip0, which controls the first PLIP device; and ifcfg-tr0, used with the first Token Ring device. A local loopback interface is often used in testing, as well as a variety of applications that require an IP address pointing back to the same system. Any data sent to the loopback device is immediately returned to the host’s network layer.

Warning

Never edit the loopback interface script, /etc/sysconfig/network-scripts/ifcfg-lo, manually. Doing so can prevent the system from operating correctly.

An infrared interface allows information between devices, such as a laptop and a printer, to flow over an infrared link that works in a similar way to an Ethernet device except that it commonly occurs over a peer-to-peer connection. A Parallel Line Interface Protocol (PLIP) connection works much the same way, except that it utilizes a parallel port. Token Ring topologies are not as common on local area networks as they once were, having been eclipsed by Ethernet.

Alias and Clone Files

Two lesser-used types of interface configuration files found in the /etc/sysconfig/network-scripts/ directory are alias and clone files. alias interface configuration files take names in the format of ifcfg-if-name:alias-value, and they allow an alias to point to an interface. For example, a ifcfg-eth0:0 file could be configured to specify DEVICE=eth0:0 and a static IP address of 10.0.0.2, serving as an alias of an Ethernet interface already configured to receive its IP information via DHCP in ifcfg-eth0. At that point, the eth0 device is bound to a dynamic IP address, but it can always be referred to on that system via the fixed 10.0.0.2 IP address.

A clone interface configuration file should follow this naming convention: ifcfg-if-name-clone-name. While an alias file is another way to refer to an existing interface configuration file, a clone file is used to specify additional options when specifying an interface. For example, if you have a standard DHCP Ethernet interface called eth0, it may look similar to this:

DEVICE=eth0 ONBOOT=yes BOOTPROTO=dhcp

Since USERCTL is set to no if it is not specified, users cannot bring this interface up and down. To give users this ability, create a clone by copying ifcfg-eth0 to ifcfg-eth0-user and add the following line:

USERCTL=yes

When a user brings up the eth0 interface with the ifup eth0-user command, the configuration options from ifcfg-eth0 and ifcfg-eth0-user are combined. While this is a very basic example, this method can be used with a variety of options and interfaces. The easiest way to create alias and clone interface configuration files is to use the GUI-based Network Administration Tool. For more on using this tool, see Chapter 13.

Категории