Quick presentation of link aggregation
General presentation
In computer networking, link aggregation (usually called bonding in the Linux kernel) is a technique that enables the combination of multiple network interfaces into one logical link. It can be implemented using different methods.
The Linux driver implements several methods of aggregation called modes. Depending on the chosen mode, the aggregation will enable:
- fault tolerance ;
- and/or network load balancing on the multiple links forming the aggregation (which allows to combine the bandwidth of each link).
According to the wikipedia page on link aggregation, the concept of link aggregation is also designated using several umbrella terms such as trunking, bundling, bonding, channeling or teaming.
The different modes of aggregation of the Linux driver
The following aggregation modes are made available by the Linux bonding driver :
balance-rr
: packets are sent out on each link in sequential order, which enables fault tolerance. It is the default mode if none are specified.active-backup
: one interface in the link must be designated as the primary interface, and will be the only one in use as long as it is available. Only if the primary interface fails will one of the other interfaces in the group be used. This mode provides fault tolerance.balance-xor
: this mode is similar tobalance-rr
, but packets are send out through one of the interfaces based on a hash policy (using the xor operation by default, but other hash policies can be selected). This mode provides both fault tolerance and load balancing.broadcast
: packets are always transmitted on all interfaces. This provides fault tolerance.802.3ad
: this mode uses all the interfaces according to the IEEE 802.3ad specification (also called Link Aggregation Control Protocol, or LACP), but this requires support of this protocol by the network switch to which the interfaces are connected (and the switch usually needs to be configured to use it on the involved ports).balance-tlb
: Transmit Load Balancing. Outgoing packets are sent on an interface chosen according to either the current load of interfaces or an hash function. Only once interface receives the packets.balance-alb
: Adaptive Load Balancing. In emission, it works likebalance-tlb
, but reception is distributed among multiple interfaces, without requiring support by the network switch (it changes the hardware address of outgoing packets to use the hardware addresses of the interfaces so that different peers see different source hardware addresses).
The above descriptions of aggregation link modes are summarized from the detailed descriptions provided in section 2 - Bonding Driver Options of the Linux Ethernet Bonding Driver HOWTO.
Configuration using the ifenslave
script
The shell script ifenslave
(provided on Debian GNU/Linux by the package
ifenslave) enables the manual configuration of a link aggregation from the
shell. Aggregation links configured this way will only use the mode
balance-rr
It requires loading the kernel module bonding
that, if not automatically
loaded, can be manually loaded using the command modprobe bonding
.
The logical interface of a aggregation group are traditionally named bond0
,
bond1
, etc.
The manual page ifenslave(8) gives a simple usage example:
This configuration naturally won't survive a reboot of the host and must
therefore be set in the network configuration file used by the system, like the
file /etc/network/interfaces
usually used on servers using Debian (which
incidentally enables choosing a different mode than balance-rr
).
Configuration through the interfaces
file on Debian
On servers running GNU/Linux, link aggregation is usually configured simply by
modifying the file /etc/network/interfaces
. On a workstation (for example to
aggregate a wired link with and a wireless one on a laptop), this configuration
should be made possible using the GUI tools for network configuration, but this
aspect will not be covered here.
The example given below will aggregate the interfaces eth0
et eth1
in a
master link bond0
using the 802.3ad
mode (i.e. the
LACP
protocol) that must usually also be configured on the network switch.
If your switch does not support this protocol, choose, according to your needs
and constraints, another mode that does not require support from the switch.
First deactivate the network interface to aggregate (using the commands ifdown eth0
and ifdown eth1
in this example), and edit the file interfaces
to use
something like this:
iface bond0 inet static
# Usual configuration of the interface
address 10.31.1.5
netmask 255.255.255.0
network 10.31.1.0
gateway 10.31.1.254
# Link aggregation configuration
bond-slaves eth0 eth1
bond-mode 802.3ad
bond-miimon 100
# The parameters below are optional
bond-updelay 200
bond-downdelay 200
One the bond0 interface activated using ifup bond0
(and if you switch has
been correctly configured if you use the 802.3ad mode), your aggregated link
should be active. The file /proc/net/bonding/bond0
will provide information
on its state (and other useful information can be found in
/sys/class/net/bond0/bonding/
).