All Red Hat Linux documents are copyrighted to Red Hat Inc.

8.2. Interface Configuration Files

Interface configuration files control the software interfaces for individual network devices. As the 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.

8.2.1. Ethernet Interfaces

One of the most common interface files is ifcfg-eth0, which controls the first Ethernet network interface card or NIC in the system. In a system with multiple NICs, there are multiple ifcfg-eth<X> files (where <X> is a unique number corresponding to a specific interface). Because each device has its own configuration file, an administrator can control how each interface functions individually.

Below 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, because IP information is provided by the DHCP server:

DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes

The Network Administration Tool (redhat-config-network) is an easy way to make changes to the various network interface configuration files (see the chapter titled Network Configuration in the Red Hat Linux Customization Guide for detailed instructions on using this tool).

However, it is also possible to edit the configuration files for a given network interface by hand.

Below is a listing of the configurable parameters in an Ethernet interface configuration file:

  • BOOTPROTO=<protocol>, where <protocol> is one of the following:

    • none — No boot-time protocol should be used.

    • bootp — The BOOTP protocol should be used.

    • dhcp — The DHCP protocol should be used.

  • BROADCAST=<address>, where <address> is the broadcast address. This directive is deprecated.

  • DEVICE=<name>, where <name> is the name of the physical device (except for dynamically-allocated PPP devices where it is the logical name).

  • DNS{1,2}=<address>, where <address> is a name server address to be placed in /etc/resolv.conf if the PEERDNS directive is set to yes.

  • IPADDR=<address>, where <address> is the IP address.

  • NETMASK=<mask>, where <mask> is the netmask value.

  • NETWORK=<address>, where <address> is the network address. This directive is deprecated.

  • ONBOOT=<answer>, where <answer> is one of the following:

    • yes — This device should be activated at boot-time.

    • no — This device should not be activated at boot-time.

  • PEERDNS=<answer>, where <answer> is one of the following:

    • yes — Modify /etc/resolv.conf if the DNS directive is set. If using DCHP, then yes is the default.

    • no — Do not modify /etc/resolv.conf.

    • SRCADDR=<address>, where <address> is the specified source IP address for outgoing packets.

    • USERCTL=<answer>, where <answer> is one of the following:

      • yes — Non-root users are allowed to control this device.

      • no — Non-root users are not allowed to control this device.

8.2.2. Dialup Interfaces

If connecting to the Internet via a dialup connection, a configuration file is necessary for the interface.

PPP interface files are named using the following format ifcfg-ppp<X> (where <X> is a unique number corresponding to a specific interface).

The PPP interface configuration file is created automatically when wvdial, the Network Administration Tool or Kppp is used to create a dialup account. The Red Hat Linux Getting Started Guide contains instructions for using these GUI-based dialup connection tools. It is also possible to create and edit this file manually.

The following is a typical ifcfg-ppp0 file:

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 dialup interface, although it is used less frequently. SLIP files have interface configuration file names such as ifcfg-sl0.

Other options, not already discussed, that may be used in these files include:

  • DEFROUTE=<answer>, where <answer> is one of the following:

    • yes — Set this interface as the default route.

    • no — Do not set this interface as the default route.

  • DEMAND=<answer>, where <answer> is one of the following:

    • yes — This interface will allow pppd to initiate a connection when someone attempts to use it.

    • no — A connection must be manually established for this interface.

  • IDLETIMEOUT=<value>, where <value> is the number of seconds of idle activity before the interface will disconnect itself.

  • INITSTRING=<string>, where <string> is the initialization string passed to the modem device. This option is primarily used with SLIP interfaces.

  • LINESPEED=<value>, where <value> is the baud rate of the device. Possible standard values here include 57600, 38400, 19200, and 9600.

  • MODEMPORT=<device>, where <device> is the name of the serial device that is used to establish the connection for the interface.

  • MTU=<value>, where <value> is the Maximum Transfer Unit (MTU) setting for the interface. The MTU refers to the largest number of bytes of data a frame can carry, not counting its header information. In some dialup situations, setting this to a value of 576 will result in fewer packets dropped and a slight improvement to the throughput for a connection.

  • NAME=<name>, where <name> is the reference to the title given to a collection of dialup connection configurations.

  • PAPNAME=<name>, where <name> is the username given during the Password Authentication Protocol (PAP) exchange that occurs to allow you to connect to a remote system.

  • PEERDNS=<answer>, where <answer> is one of the following:

    • yes — Modify the system's /etc/resolv.conf file entries to use the DNS servers provided by the remote system when a connection is established.

    • no — The /etc/resolv.conf file will not be modified.

  • PERSIST=<answer>, where <answer> is one of the following:

    • yes — This interface should be kept active at all times, even if deactivated after a modem hang up.

    • no — This interface should not be kept active at all times.

  • REMIP=<address>, where <address> is the remote system's IP address. This is usually left unspecified.

  • WVDIALSECT=<name>, where <name> associates this interface with a dialer configuration in /etc/wvdial.conf. This file contains the phone number to be dialed and other important information for the interface.

8.2.3. Other Interfaces

Other common interface configuration files that use these options include the following:

  • ifcfg-lo — A local loopback interface is often used in testing, as well as being used in 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.

    WarningWarning
     

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

  • ifcfg-irlan0 — An infrared interface allows information between devices, such as a laptop and a printer, to flow over an infrared link. This works in a similar way to an Ethernet device except that it commonly occurs over a peer-to-peer connection.

  • ifcfg-plip0 — A Parallel Line Interface Protocol (PLIP) connection works much the same way, except that it utilizes a parallel port.

  • ifcfg-tr0Token Ring topologies are not as common on Local Area Networks (LANs) as they once were, having been eclipsed by Ethernet.

8.2.4. 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, an 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 graphical Network Administration Tool. For more on using this tool, see the chapter called Network Configuration in the Red Hat Linux Customization Guide.

© Copyright 2003-2023 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.