multiple bonding interfaces in Debian GNU/Linux
by konsolentier
introduction

For redundant LAN and iSCSI
connection it is important to have multiple bonding interfaces configured on
your GNU/Linux box. Especially for iSCSI it is important to have
redundancy: Over iSCSI you have access to "disks", provided over
standard network cabling.
install ifenslave module
First of all, install the ifenslave module. To be on the safe side, let aptitude first update it's package list and then let install aptitude it's available updates. After that, let aptitude install the package ifenslave.
aptitude update
aptitude safe-upgrade
aptitude install ifenslave
aptitude install ethtool
check network adapter
If you are unsure, which physical network adapter is assigned to eth0, eth1, etc., you can use ethtool to let the LED on the network adapter blink.
ethtool -p eth0
configure /etc/modules
Open your /etc/modules file and add the following lines:
alias bond0 bonding
alias bond1 bonding
options bonding mode=2 miimon=100 downdelay=200 updelay=200 max_bonds=2
The parameter max_bonds=2 will configure the bonding module with
two interfaces, if you need more, then change the value to 3 for three
interfaces and so on.
Don't forget the line with alias bond<x>, where x reflects
the number of your bonding interfaces.
configure /etc/network/interfaces
To activate both bonding interfaces, you have to configure them in /etc/network/interfaces. The template shows how to bring up the interface eth0 and eth1 for the bond0 interface and eth2 and eth3 for the bond1 interface.
# The bond0 network interface
auto bond0
allow-hotplug bond0
iface bond0 inet static
address <ip-address>
netmask <netmask>
network <network-address>
broadcast <broadcast-address>
gateway <gateway-address>
dns-nameservers <nameserver-one> <nameserver-two>
dns-search <domain-name>
up /sbin/ifenslave bond0 eth0
up /sbin/ifenslave bond0 eth1
# The bond1 network interface
auto bond1
allow-hotplug bond1
iface bond1 inet static
address <ip-address>
netmask <netmask>
network <network-address>
broadcast <broadcast-address>
gateway <gateway-address>
dns-nameservers <nameserver-one> <nameserver-two>
dns-search <domain-name>
up /sbin/ifenslave bond1 eth2
up /sbin/ifenslave bond1 eth3
test redundancy
On your GNU/Linux Server, just watch the messages logfile to see if a patch cord is connected or disconnected.
tail -f /var/log/messages
From another GNU/Linux Box, use the following command to ping your server, the server should constantly send an ICMP echo reply back, even if you disconnect one of the patch cords of the redundant network link.
ping -t -a <ip-address>
Pull the first patch cord, watch the messages logfile on your server and
watch the ping command from your workstation.
Put the first patch cord back and then pull the second patch cord.
conclusion
With the ifenslave module you can give your GNU/Linux servers network
redundancy. If your server uses different network adapters, you can provide redundancy
on different connections, for example redundancy on LAN connection and redundancy
on iSCSI connection.
Of course it makes sense to use two switches, two different UPS's for power, etc.
to get redundancy from the hardware side.
