Network interface settings – CentOS
Configuration of the “/etc/sysconfig/network-scripts/ifcfg-eth0” file
In this file, you would find your basic network device configuration. Here, ifcfg-eth0 is the first Ethernet device; ifcfg-eth1 would be the second Ethernet NIC (network interface card), and so forth. In this file, you can have quite a few settings.
Directives | Required / Optional | Expected Settings | Comment |
DEVICE= | Required | ethX | You must have this entry specifying the Linux device name. |
ONBOOT= | Optional | yes / no | Start the device on boot? This will default to yes. |
BOOTPROTO= | Required | static / dhcp / none | Static hard set our IP, or do we want a dhcp assignment? “dhcp”, “none” is the same as static. |
IPADDR= | Optional | IP address of machine | The address we want if we are setting a static IP for the interface. |
NETMASK= | Optional | Subnet mask | Required for static IPs. The subnet mask. |
NETWORK= | Optional | Network address | Recommended for static IPs. The network that we are on. |
BROADCAST= | Optional | Network broadcast address | Recommended for static IPs. The broadcast address. |
HWADDR= | Optional | Device MAC address | The MAC address of our network card. Normally provided by the Anaconda installer at install time. |
USERCTL= | Optional | yes / no | Allow normal non-administrative user to take down and bring up the device. Defaults to “no”. |
GATEWAY= | Optional | IP address of gateway | The network gateway IP address. |
Not all of these are necessary for proper operation, and the order they are in is irrelevant. I prefer to specify the additional directives of NETWORK and BROADCAST in my /etc/sysconfig/network-scripts/ifcfg-eth0 on machines that I want to have a hard-set IP address, mainly servers of any sort. If you want to use a DHCP-assigned address, your /etc/sysconfig/network-scripts/ifcfg-eth0 file would look something like this:
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE] DEVICE=eth0 BOOTPROTO=dhcp HWADDR=08:00:27:4B:3B:06 ONBOOT=yes