Category Archives: CentOS

CentOS 6.3 NIC Bonding

NIC Bonding or Channel Bonding enables two or more network interfaces to act as one, simultaneously increasing the bandwidth and providing redundancy. If one physical NIC is down or unplugged, it will automatically move resource to another NIC card in the bond.

Step 1: Creating Bonding Channel

As root, create a new file name, bonding.conf in this example, in the /etc/modprobe.d/ directory. Insert the following line in this new file:

#vi /etc/modprobe.d/bonding.conf
alias bond0 bonding

For each configured channel bonding interface, there must be a corresponding entry in your new /etc/modprobe.d/bonding.conf file.

Step 2: Creating Channel Bonding Interface

To create a channel bonding interface, create a file in the /etc/sysconfig/network-scripts/ directory called ifcfg-bond0. The following is an example:

#vi /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
IPADDR=192.168.1.8
NETMASK=255.255.255.0
ONBOOT=yes
BOOTPRO=none
USERCTL=no

Step 3: Configuring Channel Bonding Interface

After the channel bonding interface is created, the network interfaces to be bound together must be configured by adding the MASTER and SLAVE directives to their configuration files. The configuration files for each of the channel-bonded interfaces can be nearly identical For example:

eth0

#vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
USERCTL=no
ONBOOT=bond0
SLAVE=yes
BOOTPRO=none

#vi /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPRO=none

  • DEVICE: Indicates what is the device name
  • USERCTL: Indicates if user can control this device (in this case, no)
  • ONBOOT: Indicates that at boot time should this device be up (in this case, yes)
  • MASTER: the device master (in this case bond0)
  • SLAVE: Indicates if this device is a slave
  • BOOTPRO: Where to get the IP Address from (in this case since it is set to none, it indicates a static IP)

Step 4: Restarting Network Service

Restart the network service and check the output of ifconfig

#service network restart
#ifconfig

and check to see that bond0 is UP and that eth0 and eth1 (in this case) are UP and running as SLAVE.

Force CentOS 6 to Detect New Network Devices

This is handy to know specially if you work with virtual machines. CentOS 6.x now uses udev to deal with all hardware devices. Udev managages hardware, including network interfaces, via .rules files which contain various attributes of a given piece of hardware that are used to match the device against a single device node each time it is connected to the system. When you move a virtual machine from one host to another, that copy has the original .rules files contained in it which will no longer match the new host (in terms of network connections, different MAC Address, UID, etc.). In the case of CentOS 6.x, the 70-persistent-net.rules file controls the network devices in the system and for what ever reason, CentOS 6.x does not update this file upon boot.

To force CentOS 6.x to detect the new settings, all you need to do is:

vi /etc/sysconfig/network-scripts/ifcfg-eth0

And remove the existing HWADDR line so that it won’t conflict with the new value written to the 70-persistent-net.rules file when you reboot the system. If there also exists a UID line, remove that as well.

Once you have saved the changes, all you need to do is to remove the existing 70-persistent-net.rules file by:

rm -f /etc/udev/rules.d/70-persistent-net.rules

Restart the computer or virtual machine and check that you now have network connectivity.