The system reads the network interface files during the boot process to determine which interfaces to bring up and how to configure them. The file name format of the network interface configuration file is /etc/sysconfig/network-scripts/ifcfg-eth#. So if you want to configure the interface eth0, the file to be edited is /etc/sysconfig/network-scripts/ifcfg-eth0.
Below is a sample eth0 interface configuration file.
# cat /etc/sysconfig/network-scripts/ifcfg-enp134s1f0 TYPE=Ethernet BOOTPROTO=none DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV4_FAILURE_FATAL=no NAME=eth0 UUID=... ONBOOT=yes HWADDR=0e:a5:1a:b6:fc:86 IPADDR0=172.31.24.10 PREFIX0=23 GATEWAY0=172.31.24.1 DNS1=192.168.154.3 DNS2=10.216.106.3 DOMAIN=example.com IPV6_PEERDNS=yes IPV6_PEERROUTES=yes
A description of some of these configuration parameters follows:
TYPE=device_type: The type of network interface device
BOOTPROTO=protocol: Where protocol is one of the following:
- none: No boot-time protocol is used.
- bootp: Use BOOTP (bootstrap protocol).
- dhcp: Use DHCP (Dynamic Host Configuration Protocol).
DEFROUTE|IPV6_DEFROUTE=answer: Where answer is one of the following:
- yes: This interface is set as the default route for IPv4|IPv6 traffic.
- no: This interface is not set as the default route.
IPV6INIT=answer: Where answer is one of the following:
- yes: Enable IPv6 on this interface. If IPV6INIT=yes, the following parameters could also be set in this file:
- IPV6ADDR=IPv6 address
- IPV6_DEFAULTGW=The default route through the specified gateway
IPV4_FAILURE_FATAL|IPV6_FAILURE_FATAL=answer: Where answer is one of the following:
- yes: This interface is disabled if IPv4 or IPv6 configuration fails.
- no: This interface is not disabled if configuration fails.
ONBOOT=answer: Where answer is one of the following:
- yes: This interface is activated at boot time.
- : This interface is not activated at boot time.
HWADDR=MAC-address: The hardware address of the Ethernet device
IPADDRN=address: The IPv4 address assigned to the interface
PREFIXN=N: Length of the IPv4 netmask value
GATEWAYN=address: The IPv4 gateway address assigned to the interface. Because an interface can be associated with several combinations of IP address, network mask prefix length, and gateway address, these are numbered starting from 0.
DNSN=address: The address of the Domain Name Servers (DNS)
DOMAIN=DNS_search_domain: The DNS search domain
Additional Network Configuration Files
In addition to the individual network interface configuration files in the /etc/sysconfig/network-scripts directory, there are other, more global network configuration files. These files are:
This file associates host names with IP addresses. It resolves or looks up, an IP address when the hostname is known. Larger networks would use Domain Name Service (DNS) to perform this resolution. Even if using DNS, include in this file a line specifying the IP address of the loopback device (127.0.0.1) as localhost.localdomain. A sample /etc/hosts file follows. The first column contains the IP address. The second column is the fully qualified hostnames. Additional columns contain hostname aliases:
# cat /etc/hosts 127.0.0.1 localhost.localdomain localhost 192.0.2.101 host01.example.com. host01
The resolver configuration file provides access to DNS. This file usually has at least two lines, one line specifying the IP address of a DNS server (or name server) and the other specifying the search domain. The following example shows three name servers and the search domain:
# cat /etc/resolv.conf search example.com nameserver 192.168.154.2 nameserver 18.104.22.168 nameserver 22.214.171.124
This file specifies global network settings. For example, you can specify the default gateway in this file:
# cat /etc/sysconfig/network GATEWAY=192.168.2.1
This file is the system databases and name service switch configuration file. It provides sources for common configuration databases and name resolution mechanisms. Entries in this file identify the database name in the first field, then a colon, and then a list of possible resolution mechanisms in the second field. The order in which the mechanisms are listed determines the order in which queries on the specified database are resolved.
The following example indicates that host name resolution is attempted first by querying local files, that is, /etc/hosts, and then by querying the DNS server if the host name is not resolved:
# cat /etc/nsswitch.conf ... hosts: files dns ...