Link aggregation (also known as "Ethernet trunk", "NIC teaming", "port teaming", "port trunking", etc) allows you to use multiple NICs in parallel to increase the link speed beyond the limits of any one single cable or port, and to increase the redundancy for higher availability.
Although this feature can be incredibly useful for increasing the available bandwidth to file servers, I must say that I have primarily used this in order to provide resilient network connectivity to mission critical servers.Setting up a single bonded interface is quite simple, and well documented. However, setting up multiple bonded interfaces on a single system is a little more tricky!
In this example, we will configure two bonded interfaces. bond0 will be connected to our main infrastructure, and will operate in an active-active configuration. bond1 will be connected to our management network, and will feature active-passive failover.
First, we set up the bondx and ifcfg-ethx configuration files in /etc/sysconfig/network-scripts/ as commonly documented. So, our bonded connection (bond0) will feature eth0 and eth1:
And, now we configure bond1 to use eth2 and eth3.
Now we need to configure /etc/modprobe.conf. This is where the 'trick' is. Rather than let modprobe work out the card options itself, we explicitly specify 'install' and 'remove' commands to execute when the module is loaded and unloaded.
alias bond0 bonding
alias bond1 bonding
install bond0 /sbin/modprobe –ignore-install -o bonding0 bonding mode=0 miimon=100
remove bond0 /sbin/modprobe -r –ignore-remove bonding0
install bond1 /sbin/modprobe –ignore-install -o bonding1 bonding mode=1 miimon=100
remove bond1 /sbin/modprobe -r –ignore-remove bonding1
For reference, the 'mode' parameters configures how the slave interfaces should behave. There are four available modes:
- 0 — Sets a round-robin policy for fault tolerance and load balancing. Transmissions are received and sent out sequentially on each bonded slave interface beginning with the first one available.
- 1 — Sets an active-backup policy for fault tolerance. Transmissions are received and sent out via the first available bonded slave interface. Another bonded slave interface is only used if the active bonded slave interface fails.
- 2 — Sets an XOR (exclusive-or) policy for fault tolerance and load balancing. Using this method the interface matches up the incoming request's MAC address with the MAC address for one of the slave NICs. Once this link is established, transmissions are sent out sequentially beginning with the first available interface.
- 3 — Sets a round-robin policy for fault tolerance and load balancing. Transmissions are sent out sequentially on each bonded slave interface beginning with the first one available.
The "miimon" options dictates how often MII link monitoring occurs in milliseconds. This is useful if high availability is required because MII is used to verify that the NIC is active. There are other options such as "updelay" and "downdelay" that control how long we wait before enabling or disabling a link.