What is bonding?
Bonding is the same as port trunking. In the following I will use the word bonding because practically we will bond interfaces as one.
But still… what is bonding?
Bonding allows you to aggregate multiple ports into a single group, effectively combining the bandwidth into a single connection. Bonding also allows you to create multi-gigabit pipes to transport traffic through the highest traffic areas of your network. For example, you can aggregate three megabits ports (1 mb each) into a three-megabits trunk port. That is equivalent with having one interface with three megabits speed.
Where should I use bonding?
You can use it wherever you need redundant links, fault tolerance or load balancing networks. It is the best way to have a high availability network segment. A very useful way to use bonding is to use it in connection with 802.1q VLAN support (your network equipment must have 802.1q protocol implemented).
The example below is for bonding 2 network interfaces to 1 IP address. Both network cards will then share IP address 10.0.0.10. This was performed on a Fedora 10 linux workstation. The file locations should transfer to RedHat Enterprise Linux (RHEL) and CentOS, but not Debian based distros (e.g., Ubuntu).
Create the file: /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0 ONBOOT=yes BOOTPROTO=none USERCTL=no PEERDNS=no IPV6INIT=no NM_CONTROLLED=no TYPE=Ethernet NETMASK=255.255.255.0 IPADDR=10.0.0.10 GATEWAY=10.0.0.1
Then, for each interface (network card) you want to bond to the bond0 interface, edit the respective device’s configuration file: /etc/sysconfig/network-scripts/ifcfg-[interface] (e.g., eth0, eth1, ra0)
DEVICE=[match to the interface you're mapping] (e.g., eth0, eth1, ra0) MASTER=bond0 SLAVE=yes ONBOOT=yes BOOTPROTO=none USERCTL=no PEERDNS=no IPV6INIT=no NM_CONTROLLED=no TYPE=Ethernet
Then create and edit /etc/modprobe.conf (or modules.conf for RHEL) and add the following lines:
alias bond0 bonding options bonding miimon=100 mode=1
I chose to use mode=1 which is “active backup mode.” mode=0 is “round-robin.” What does that mean? Definitions are below. (There are several “modes,” but these 4 are the most popular.)
Round-robin policy: Transmit packets in sequential order from the first available slave through the last. This mode provides load balancing and fault tolerance.
Active-backup policy: Only one slave in the bond is active. A different slave becomes active if, and only if, the active slave fails. The bond’s MAC address is externally visible on only one port (network adapter) to avoid confusing the switch. This mode provides fault tolerance. The primary option affects the behavior of this mode.
Broadcast policy: transmits everything on all slave interfaces. This mode provides fault tolerance.
IEEE 802.3ad Dynamic link aggregation. Creates aggregation groups that share the same speed and duplex settings. Utilizes all slaves in the active aggregator according to the 802.3ad specification.
A service network restart is all that was needed to activate bond0. If not, a reboot will do it.
The best documentation is found on the Linux Channel Bonding Project page