Ethernet bonding refers to aggregating multiple ethernet channels together to form a single channel. This is primarily used for redundancy in ethernet paths or for load balancing. This page refers in particular to performing ethernet bonding under linux, and so does not limit itself to discussion of 802.3ad Trunk Aggregation.
The linux kernel bonding module supports a number of bonding types.
You need the bonding module for your kernel, and the ifenslave tool which is found within the kernel source at Documentation/networking/ifenslave.c, or you could use a distribution provided package (eg, apt-get install ifenslave-2.4 or apt-get install ifenslave-2.6 depending on your kernel version).
It is recommended that you let the kernel know which module to use for the bonded interface by setting the following in the appropriate place for module options (for debian it is /etc/modutils/aliases):
alias bond0 bonding
When loading the bonding module, you must specify the mode you wish to use. It's normally best to set this as a modprobe option, the location of which will depend on your distribution. For debian, you could set it in /etc/modutils/options and run update-modules
Read the kernel docs for which options are supported. At a minimum, you have to set the bonding mode you wish to use, eg:
options bond0 mode=802.3ad miimon=100
To bond eth0 and eth1 into the bonded device bond0, and assign this device the IP address 192.168.1.1 within the 192.168.1.0/24 network, do the following:
ifconfig bond0 192.168.1.1 netmask 255.255.255.0 up ifenslave bond0 eth0 ifenslave bond0 eth1
During a setup I did recently (February 2006) using active-backup, I had to change the MAC address of the interface that was ifenslaved second to be the same as the first. It seemed that something weird was happening like the second interface would answer an ARP request for an IP address, and provide the MAC address of the bridge, but the machine never got packets, because it wouldn't accept packets for anything other than the MAC of the second interface. I didn't investigate further, it could have been something I was doing wrong. -- MichaelJager (IsomerMadeMeDoThis)
Your distribution will possibly have native interface control support for creating bonded interfaces. Check your manual pages. RedHat and SuSE (and derivatives) have native support; debian doesn't appear to.
auto eth0 eth1 bond0 iface eth0 inet manual iface eth1 inet manual iface bond0 inet static pre-up ifconfig bond0 up pre-up ifenslave bond0 eth0 eth1 pre-down ifenslave -d bond0 eth0 eth1 address 192.168.1.1 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 gateway 192.168.1.254
There is a mailing list post which contains some hook scripts for debian to provide ifupdown bonded interface functionality. These can be found here
You can specify VLAN interfaces on top of a bonded interface. Simply assign the bond0 interface no IP address (or 0.0.0.0), and then you can use the bond0 interface as the physical device for the VLAN interface. Refer to your distribution documentation on how to setup vlans within your network configuration.
I've done this, and it works well. I wanted to use bridging at let STP work out which interface to put into forwarding, and which to put into blocking, but the bridging driver didn't work with per-VLAN spanning tree; as a result I ended up using bonding in active-backup mode. -- MichaelJager