Is your machine has two or more network interface?
Bonding is same as port trunking. Both word refers to same technique.
Technically speaking, bonding will aggregate two or more ports (network interfaces / NIC) into a single group. It will effectively combine them into a single connection, using only one IP address. It allows us to create multi-gigabit pipes to transport traffic through the highest traffic areas of our network.
Imagine we have three megabits ports into one three-megabits trunk port. This is equivalent with having three megabits speed. While in upper layer, we only need to manage one interface which is the bonding channel.
In this article we will discuss about how to implement bonding on CentOS, in specific to CentOS 6.
Bonding have several modes of operations which will determines the bond’s behavior.
- mode 1: active-backup
- Only one slace in the bond is active. A different slave become active if and only if the active slave fails. The bond’s MAC address is externally visible on only one port (network adapter).
- mode 2: balance-xor
- Transmit based on [ (source MAC address XOR’d with destination MAC address) modulo slave count ]. It looks confusing but it is pretty straightforward. This selects the same slave for each destination MAC address. This mode provides load balancing and fault tolerance.
- mode 3: broadcast
- Transmit everything on all slave interfaces. This mode provides fault tolerance
- mode 4: 802.3ad
- Refers to IEEE 802.3ad Dynamic Link Aggregation. Create aggregation gorups that share the same speed and duplex settings. It will utilizes all slaves in the active aggregator according to 802.3ad specification. To use this method we need a switch that supports IEEE 802.3ad Dynamic LInk Aggregation. Most switches will require some type of configuration.
- mode 5: balance-tlb
- Adaptive transmit load balancing. No special switch support. The outgoing traffic is distributed according to the current load which is computed relative to the speed on each slave. Incoming traffic is received by current slave. If the receiving slave fails, another slave takes over the MAC address of the failed receiving slave.
- mode 6: balance-alb
- Adaptive load balancing. Similar to tlb (transmit load balancing) but also use receive load balancing (rlb) for IPv5 traffic. The receive load balancing is achieved by ARP negotiation. The bonding driver intercepts the ARP replies sented by the local system on their way out and overwrites the source hardwares address with the unique hardware address of on of the slaves in the bond such that different peers use different hardware address for the server.
For more information, please refers to Linux Channel Bonding Project: http://sourceforge.net/projects/bonding/
Creating a Bonding Channel
Edit /etc/modprobe.conf, make new file if it doesn’t exists. Then write these lines into it:
alias bond0 bonding
options bond0 miimon=80 mode=<mode>
<mode> is the bonding mode, refer to previous section for description of each mode. In this article we will use mode 5.
Next we create a logical interface. Edit /etc/sysconfig/network-scripts/ifcfg-bond0 (bond-zero) or create it if it doesn’t exists.
Adjust the content with your condition. In this scenario, the bond channel have IP address 192.168.1.103/24. The bond channel is avalable on boot.
At this point, we have create a bonding channel.
Suppose we have two interface, eth0 and eth1 and want to aggregate them into bond0. The eth0 and eth1 will be the slave.
Edit /etc/sysconfig/network-scripts/ifcfg-eth0 or your file corresponded to eth0
Edit /etc/sysconfig/network-scripts/ifcfg-eth1 or your file corresponded to eth1
Then restart the network service.
service network restart