Este conteúdo não está disponível no idioma selecionado.
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
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:
DEVICE=eth0 BOOTPROTO=none ONBOOT=yes 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 different because IP
information is provided by the DHCP
server:
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 inbonding
Module 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_OPTS
directive inifcfg-name
files. 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
— TheBOOTP
protocol should be used.dhcp
— TheDHCP
protocol 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
PPP
devices where it is the logical name). DHCP_HOSTNAME
=name- where name is a short host name to be sent to the
DHCP
server. Use this option only if theDHCP
server requires the client to specify a host name before receiving anIP
address. DHCPV6C
=answer- where answer is one of the following:
yes
— UseDHCP
to obtain anIPv6
address for this interface.no
— Do not useDHCP
to obtain anIPv6
address for this interface. This is the default value.
AnIPv6
link-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
— EnableIPv6
prefix delegation.-S
— UseDHCP
to obtain stateless configuration only, not addresses, for this interface.-N
— Restore normal operation after using the-T
or-P
options.-T
— UseDHCP
to obtain a temporaryIPv6
address for this interface.-D
— Override the default when selecting the type of DHCP Unique Identifier (DUID) to use.By default, theDHCP
client (dhclient) creates a DHCP Unique Identifier (DUID) based on the link-layer address (DUID-LL) if it is running in stateless mode (with the-S
option, 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-D
option overrides this default, with a value of eitherLL
orLLT
.
DNS{1,2}
=address- where address is a name server address to be placed in
/etc/resolv.conf
provided that thePEERDNS
directive 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"
Instead of a custom initscript, useETHTOOL_OPTS
to 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 off
option. 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=no
option 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
. HWADDR
must 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.
-
IPADDR
n=address - where address is the
IPv4
address 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,
IPv6
address on an interface.The format is Address/Prefix-length. If no prefix length is specified,/64
is assumed. Note that this setting depends onIPV6INIT
being enabled. -
IPV6ADDR_SECONDARIES
=address - where address is one or more, space separated, additional
IPv6
addresses.The format is Address/Prefix-length. If no prefix length is specified,/64
is assumed. Note that this setting depends onIPV6INIT
being enabled. -
IPV6INIT
=answer - where answer is one of the following:
yes
— Initialize this interface forIPv6
addressing.no
— Do not initialize this interface forIPv6
addressing. This is the default value.This setting is required forIPv6
static andDHCP
assignment ofIPv6
addresses. 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
— EnableIPv6
autoconf configuration for this interface.no
— DisableIPv6
autoconf configuration for this interface.
If enabled, anIPv6
address will be requested using Neighbor Discovery (ND) from a router running theradvd
daemon.Note that the default value ofIPV6_AUTOCONF
depends onIPV6FORWARDING
as follows:- If
IPV6FORWARDING
=yes
, thenIPV6_AUTOCONF
will default tono
. - If
IPV6FORWARDING
=no
, thenIPV6_AUTOCONF
will default toyes
andIPV6_ROUTER
has 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
IPV6INIT
option 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-64
method. 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::/64
as 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
STP
for 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
HWADDR
directive. -
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
SLAVE
directive.See Section 11.2.4, “Channel Bonding Interfaces” for more information about channel bonding interfaces. -
NETMASK
n=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_CONTROLLED
directive is now, as of Red Hat Enterprise Linux 6.3, dependent on theNM_BOND_VLAN_ENABLED
directive 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.conf
if theDNS
directive is set, if usingDHCP
, or if using Microsoft's RFC 1877IPCP
extensions withPPP
. In all casesyes
is 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 theMASTER
directive.no
— This device is not controlled by the channel bonding interface specified in theMASTER
directive.
This directive is used in conjunction with theMASTER
directive.See Section 11.2.4, “Channel Bonding Interfaces” for more about channel bonding interfaces. -
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.