The configuration files for network interfaces are located in the
/etc/sysconfig/network-scripts/
directory.
The scripts used to activate and deactivate these network interfaces are also located here. Although the number and type of interface files can differ from system to system, there are three categories of files that exist in this directory:
-
Interface configuration files
-
Interface control scripts
-
Network function files
The files in each of these categories work together to enable various network devices.
1、/etc/hosts
The main purpose of this file is to resolve hostnames that cannot be resolved any other way. It can also be used to resolve hostnames on small networks with no DNS server. Regardless of the type of network the computer is on, this file should contain a line specifying the IP address of the loopback device (
127.0.0.1
) as localhost.localdomain
.
2、/etc/resolv.conf:
This file specifies the IP addresses of DNS servers and the search domain. Unless configured to do otherwise, the network initialization scripts populate this file.
3、/etc/sysconfig/network:
This file specifies routing and host information for all network interfaces.
NETWORKING=
boolean:A boolean to enable (yes
) or disable (no
) the networking.
HOSTNAME=value:The hostname of the machine.
GATEWAY=value:The IP address of the network's gateway.
4、/etc/sysconfig/network-scripts/ifcfg-interface-name
For each network interface, there is a corresponding interface configuration script. Each of these files provide information specific to a particular network interface.
(1)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.
(2)BROADCAST=address
where address is the broadcast address. This directive is deprecated, as the value is calculated automatically with ipcalc.
(3)DEVICE=name
where name is the name of the physical device (except for dynamically-allocated PPP devices where it is the logical name).
(4)DHCP_HOSTNAME=name
where name is a short hostname to be sent to the DHCP server. Use this option only if the DHCP server requires the client to specify a hostname before receiving an IP address.
(5)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.
(6)GATEWAY=address
where address is the IP address of the network router or gateway device (if any).
(7)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.
(8)PEERDNS=answer
where answer is one of the following:
yes — Modify /etc/resolv.conf if the DNS directive is set. If using DHCP, then yes is the default.
no — Do not modify /etc/resolv.conf.
(9)SRCADDR=address
where address is the specified source IP address for outgoing packets.
(10) 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.
(11)NETMASK=mask
where mask is the netmask value.
(12)NETWORK=address
where address is the network address. This directive is deprecated, as the value is calculated automatically with ipcalc.
(13)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.
(14)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
(15)BONDING_OPTS=parameters
sets the configuration parameters for the bonding device, and is used in /etc/sysconfig/network-scripts/ifcfg-bondN (see Section 6.2.2, “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 in bonding Module Directives.
This configuration method is used so that multiple bonding devices can have different configurations. It is highly recommended to place all of your bonding options after the BONDING_OPTS directive in ifcfg-name. Do not specify options for the bonding device in /etc/modprobe.d/bonding.conf, or in the deprecated /etc/modprobe.conf file.
sets the configuration parameters for the bonding device, and is used in /etc/sysconfig/network-scripts/ifcfg-bondN (see Section 6.2.2, “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 in bonding Module Directives.
This configuration method is used so that multiple bonding devices can have different configurations. It is highly recommended to place all of your bonding options after the BONDING_OPTS directive in ifcfg-name. Do not specify options for the bonding device in /etc/modprobe.d/bonding.conf, or in the deprecated /etc/modprobe.conf file.
(16)MASTER=bond-interface
where bond-interface is the channel bonding interface to which the Ethernet interface is linked.
where bond-interface is the channel bonding interface to which the Ethernet interface is linked.
(17)SLAVE=answer
where answer is one of the following:
yes — This device is controlled by the channel bonding interface specified in the MASTER directive.
no — This device is not controlled by the channel bonding interface specified in the MASTER directive.
where answer is one of the following:
yes — This device is controlled by the channel bonding interface specified in the MASTER directive.
no — This device is not controlled by the channel bonding interface specified in the MASTER directive.
5、Alias and Clone Files
Alias interface configuration files, which are used to bind multiple addresses to a single interface, use the ifcfg-if-name
:alias-value
naming scheme. Alias interfaces do not support DHCP.
A clone interface configuration file should use the following naming convention: ifcfg-if-name
-clone-name. a clone file is used to specify additional options for an interface.
6、The /etc/sysconfig/networking/
directory is used by the Network Administration Tool (system-config-network
) and its contents should not be edited manually.