11.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.
11.2.1. Ethernet Interfaces Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
One of the most common interface files is
/etc/sysconfig/network-scripts/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-ethX 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.
The following is a sample
ifcfg-eth0 file for a system using a fixed IP address:
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 different because IP information is provided by the DHCP server:
DEVICE=eth0 BOOTPROTO=dhcp ONBOOT=yes
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
NetworkManager is graphical configuration tool which provides an easy way to make changes to the various network interface configuration files (see Chapter 10, NetworkManager for detailed instructions on using this tool).
However, it is also possible to manually edit the configuration files for a given network interface.
Below is a listing of the configurable parameters in an Ethernet interface configuration file:
-
BONDING_OPTS=parameters - sets the configuration parameters for the bonding device, and is used in
/etc/sysconfig/network-scripts/ifcfg-bondN(see Section 11.2.4, “Channel Bonding Interfaces”). These parameters are identical to those used for bonding devices in/sys/class/net/bonding_device/bonding, and the module parameters for the bonding driver as described inbondingModule Directives.This configuration method is used so that multiple bonding devices can have different configurations. In Red Hat Enterprise Linux 6, place all interface-specific bonding options after theBONDING_OPTSdirective inifcfg-namefiles. See Where to specify bonding module parameters for more information. -
BOOTPROTO=protocol - where protocol is one of the following:
none— No boot-time protocol should be used.bootp— TheBOOTPprotocol should be used.dhcp— TheDHCPprotocol should be used.
BROADCAST=address- where address is the broadcast address. This directive is deprecated, as the value is calculated automatically with
ipcalc. -
DEVICE=name - where name is the name of the physical device (except for dynamically-allocated
PPPdevices where it is the logical name). DHCP_HOSTNAME=name- where name is a short host name to be sent to the
DHCPserver. Use this option only if theDHCPserver requires the client to specify a host name before receiving anIPaddress. DHCPV6C=answer- where answer is one of the following:
yes— UseDHCPto obtain anIPv6address for this interface.no— Do not useDHCPto obtain anIPv6address for this interface. This is the default value.
AnIPv6link-local address will still be assigned by default. The link-local address is based on the MAC address of the interface as per RFC 4862. DHCPV6C_OPTIONS=answer- where answer is one of the following:
-P— EnableIPv6prefix delegation.-S— UseDHCPto obtain stateless configuration only, not addresses, for this interface.-N— Restore normal operation after using the-Tor-Poptions.-T— UseDHCPto obtain a temporaryIPv6address for this interface.-D— Override the default when selecting the type of DHCP Unique Identifier (DUID) to use.By default, theDHCPclient (dhclient) creates a DHCP Unique Identifier (DUID) based on the link-layer address (DUID-LL) if it is running in stateless mode (with the-Soption, to not request an address), or it creates an identifier based on the link-layer address plus a timestamp (DUID-LLT) if it is running in stateful mode (without-S, requesting an address). The-Doption overrides this default, with a value of eitherLLorLLT.
DNS{1,2}=address- where address is a name server address to be placed in
/etc/resolv.confprovided that thePEERDNSdirective is not set tono. -
ETHTOOL_OPTS=options - where options are any device-specific options supported by
ethtool. For example, if you wanted to force 100Mb, full duplex:ETHTOOL_OPTS="autoneg off speed 100 duplex full"
ETHTOOL_OPTS="autoneg off speed 100 duplex full"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Instead of a custom initscript, useETHTOOL_OPTSto set the interface speed and duplex settings. Custom initscripts run outside of the network init script lead to unpredictable results during a post-boot network service restart.Important
Changing speed or duplex settings almost always requires disabling auto-negotiation with theautoneg offoption. This option needs to be stated first, as the option entries are order-dependent.See Section 11.8, “Ethtool” for more ethtool options. HOTPLUG=answer- where answer is one of the following:
yes— This device should be activated when it is hot-plugged (this is the default option).no— This device should not be activated when it is hot-plugged.
TheHOTPLUG=nooption can be used to prevent a channel bonding interface from being activated when a bonding kernel module is loaded.See Section 11.2.4, “Channel Bonding Interfaces” for more information about channel bonding interfaces. -
HWADDR=MAC-address - where MAC-address is the hardware address of the Ethernet device in the form AA:BB:CC:DD:EE:FF. This directive must be used in machines containing more than one NIC to ensure that the interfaces are assigned the correct device names regardless of the configured load order for each NIC's module. This directive should not be used in conjunction with
MACADDR.Note
- Persistent device names are now handled by
/etc/udev/rules.d/70-persistent-net.rules. HWADDRmust not be used with System z network devices.- See Section 25.3.3, "Mapping subchannels and network device names", in the Red Hat Enterprise Linux 6 Installation Guide.
-
IPADDRn=address - where address is the
IPv4address and the n is expected to be consecutive positive integers starting from 0 (for example, IPADDR0). It is used for configurations with multiple IP addresses on an interface. It can be omitted if there is only one address being configured. -
IPV6ADDR=address - where address is the first static, or primary,
IPv6address on an interface.The format is Address/Prefix-length. If no prefix length is specified,/64is assumed. Note that this setting depends onIPV6INITbeing enabled. -
IPV6ADDR_SECONDARIES=address - where address is one or more, space separated, additional
IPv6addresses.The format is Address/Prefix-length. If no prefix length is specified,/64is assumed. Note that this setting depends onIPV6INITbeing enabled. -
IPV6INIT=answer - where answer is one of the following:
yes— Initialize this interface forIPv6addressing.no— Do not initialize this interface forIPv6addressing. This is the default value.This setting is required forIPv6static andDHCPassignment ofIPv6addresses. It does not affect IPv6 Stateless Address Autoconfiguration (SLAAC) as per RFC 4862.See Section D.1.14, “/etc/sysconfig/network” for information on disablingIPv6.
-
IPV6_AUTOCONF=answer - where answer is one of the following:
yes— EnableIPv6autoconf configuration for this interface.no— DisableIPv6autoconf configuration for this interface.
If enabled, anIPv6address will be requested using Neighbor Discovery (ND) from a router running theradvddaemon.Note that the default value ofIPV6_AUTOCONFdepends onIPV6FORWARDINGas follows:- If
IPV6FORWARDING=yes, thenIPV6_AUTOCONFwill default tono. - If
IPV6FORWARDING=no, thenIPV6_AUTOCONFwill default toyesandIPV6_ROUTERhas no effect.
-
IPV6_MTU=value - where value is an optional dedicated MTU for this interface.
-
IPV6_PRIVACY=rfc3041 - where rfc3041 optionally sets this interface to support RFC 3041 Privacy Extensions for Stateless Address Autoconfiguration in IPv6. Note that this setting depends on
IPV6INIToption being enabled.The default is for RFC 3041 support to be disabled. Stateless Autoconfiguration will derive addresses based on the MAC address, when available, using the modifiedEUI-64method. The address is appended to a prefix but as the address is normally derived from the MAC address it is globally unique even when the prefix changes. In the case of a link-local address the prefix isfe80::/64as per RFC 2462 IPv6 Stateless Address Autoconfiguration. -
LINKDELAY=time - where time is the number of seconds to wait for link negotiation before configuring the device. The default is 5 secs. Delays in link negotiation, caused by
STPfor example, can be overcome by increasing this value. -
MACADDR=MAC-address - where MAC-address is the hardware address of the Ethernet device in the form AA:BB:CC:DD:EE:FF.This directive is used to assign a MAC address to an interface, overriding the one assigned to the physical NIC. This directive should not be used in conjunction with the
HWADDRdirective. -
MASTER=bond-interface - where bond-interface is the channel bonding interface to which the Ethernet interface is linked.This directive is used in conjunction with the
SLAVEdirective.See Section 11.2.4, “Channel Bonding Interfaces” for more information about channel bonding interfaces. -
NETMASKn=mask - where mask is the netmask value and the n is expected to be consecutive positive integers starting from 0 (for example, NETMASK0). It is used for configurations with multiple IP addresses on an interface. It can be omitted if there is only one address being configured.
-
NETWORK=address - where address is the network address. This directive is deprecated, as the value is calculated automatically with
ipcalc. -
NM_CONTROLLED=answer - where answer is one of the following:
yes— NetworkManager is permitted to configure this device. This is the default behavior and can be omitted.no— NetworkManager is not permitted to configure this device.
Note
TheNM_CONTROLLEDdirective is now, as of Red Hat Enterprise Linux 6.3, dependent on theNM_BOND_VLAN_ENABLEDdirective in/etc/sysconfig/network. If and only if that directive is present and is one ofyes,y, ortrue, will NetworkManager detect and manage bonding and VLAN interfaces. 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.confif theDNSdirective is set, if usingDHCP, or if using Microsoft's RFC 1877IPCPextensions withPPP. In all casesyesis the default.no— Do not modify/etc/resolv.conf.
SLAVE=answer- where answer is one of the following:
yes— This device is controlled by the channel bonding interface specified in theMASTERdirective.no— This device is not controlled by the channel bonding interface specified in theMASTERdirective.
This directive is used in conjunction with theMASTERdirective.See Section 11.2.4, “Channel Bonding Interfaces” for more about channel bonding interfaces. -
SRCADDR=address - where address is the specified source
IPaddress for outgoing packets. -
USERCTL=answer - where answer is one of the following:
yes— Non-rootusers are allowed to control this device.no— Non-rootusers are not allowed to control this device.