How to Fix Missing ifcfg-eth1 When Adding Secondary Network Interface in CentOS VirtualBox


4 views

When you add a secondary network interface in VirtualBox for a CentOS 6.7 minimal installation, the system doesn't automatically create the corresponding network configuration file (ifcfg-eth1) in /etc/sysconfig/network-scripts/. This is different from some modern Linux distributions where new interfaces are automatically configured.

CentOS (and RHEL) systems use configuration files in /etc/sysconfig/network-scripts/ to manage network interfaces. Each file follows the naming convention ifcfg-ethX where X is the interface number.

# Example of a basic ifcfg-eth0 file
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
TYPE=Ethernet

You'll need to create the configuration file yourself. Here's how:

# Create a new configuration file
sudo vi /etc/sysconfig/network-scripts/ifcfg-eth1

# Add these basic contents (adjust as needed):
DEVICE=eth1
BOOTPROTO=dhcp
ONBOOT=yes
TYPE=Ethernet

While you can edit these files manually, there are tools that can help:

  1. system-config-network (GUI tool, requires X11)
  2. nmtui (text-based UI, available in newer versions)
  3. nmcli (command-line tool for NetworkManager)

To install system-config-network:

sudo yum install system-config-network

After creating the configuration file, you can start the interface:

sudo ifup eth1

To check the interface status:

ip link show eth1
ip addr show eth1

Ensure your interface comes up automatically at boot by:

  1. Setting ONBOOT=yes in the configuration file
  2. Verifying the network service is enabled:
sudo chkconfig network on
sudo service network restart

When adding a secondary network interface to a CentOS 6.7 minimal installation in VirtualBox, you'll notice the system detects the new interface (eth1) but fails to bring it up automatically. This occurs because:

  • CentOS 6.x doesn't auto-generate interface configuration files for new NICs
  • The network service requires explicit configuration in /etc/sysconfig/network-scripts

The key files involved are:

/etc/sysconfig/network-scripts/ifcfg-eth0  # Primary interface
/etc/sysconfig/network-scripts/ifcfg-eth1  # Missing secondary interface
/etc/udev/rules.d/70-persistent-net.rules  # NIC naming rules

Here's how to properly configure the secondary interface:

1. Verify Interface Detection

# Check detected interfaces
ip link show
# Should show both eth0 and eth1

2. Create ifcfg-eth1 Manually

Copy the existing eth0 config as a template:

cd /etc/sysconfig/network-scripts
cp ifcfg-eth0 ifcfg-eth1

Then modify ifcfg-eth1 with these essential parameters:

DEVICE="eth1"
BOOTPROTO="static"  # or "dhcp" if using DHCP
IPADDR="192.168.56.10"  # Example for Host-Only network
NETMASK="255.255.255.0"
ONBOOT="yes"
NM_CONTROLLED="no"

3. Update MAC Address

Get the MAC address from VirtualBox settings or via:

ip link show eth1 | awk '/ether/ {print $2}'

Add this to ifcfg-eth1:

HWADDR="08:00:27:XX:XX:XX"

For more complex setups:

Bonding Interfaces

# Create bond0 config
DEVICE=bond0
TYPE=Bond
BONDING_MASTER=yes
BONDING_OPTS="mode=1 miimon=100"

VLAN Configuration

# Example VLAN config
DEVICE=eth1.100
VLAN=yes
PHYSDEV=eth1
  • Check logs: tail -f /var/log/messages
  • Test connectivity: ping -I eth1 192.168.56.1
  • Restart networking: service network restart

When editing network configs:

  • Always backup original files
  • Verify syntax with service network restart before reboot
  • Consider using chattr +i on production configs