Monday, November 5, 2012

[OS] Bonding Network Interfaces

NIC Bonding (or NIC Teaming) is a way to increase available bandwidth where two network interface cards appear to be the same physical device and share the same MAC address. The Linux kernel module bonding allows this functionality.

First of all, you need to know the hardware addresses for the network cards. Example: eth0, eth1, eth2.

Secondly, touch a file for the new bonded interface called ifcfg-bond0 on the directory /etc/sysconfig/network-scripts.

In the ifcfg-bond0 file add the following lines:
DEVICE=bond0
BOOTPROTO=none
ONBOOT=yes
NETWORK=<network_address>
NETMASK=<netmask>
IPADDR=<ip_address>
USERCTL=no
GATEWAY=<gateway_address>
TYPE=Ethernet
Then modify the ifcfg file for each interface you want to bond. In this case, edit ifcfg-eth0 and ifcfg-eth1.

ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=yes
ifcfg-eth1
DEVICE=eth1
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=yes
After that, modify the file /etc/modprobe.conf and add the following lines:
alias bond0 bonding
options bond0 miimon=100 mode=1

Finally, restart the network service (service network restart) or restart the server (init 6).

Problem solved!