How to Setup Network Bonding with Debian 6

Posted on by admin

How to Setup Network Bonding with Debian 6

In order to setup either load balancing or redundant NICS on your Debian server, you will need at least two NICS connected to either different switches (failover and possible load balancing) or the same switch (load balancing only).
First off, you need to install the bonding module by:

#sudo apt-get install ifenslave-2.6
#sudo modprobe bonding && echo bonding >> /etc/modules

This will install the module as well as load the module at boot.
Now we need to edit the /etc/network/interfaces file as follows:

#sudo cp /etc/network/interfaces /etc/network/
#sudo vi /etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto bond0
iface bond0 inet static
bond-mode balance-rr
bond-miimon 100
bond-downdelay 200
bond_updelay 200
slaves eth0 eth1

Reboot and test by checking that bond0 is UP and that eth0 and eth1 (in this case) are UP and running as SLAVE.

A Note About Various Bonding Policies

In the above example bounding policy (mode) is set to 0 or balance-rr. Other possible values are as follows:

The Linux bonding driver aggregating policies
Bonding policies (mode) Description
balance-rr or 0 Round-robin policy to transmit packets in sequential order from the first available slave through the last. This mode provides load balancing and fault tolerance.
active-backup or 1 Active-backup policy. Only one slave in the bond is active. A different slave becomes active if, and only if, the active slave fails. This mode provides fault tolerance.
balance-xor or 2 Transmit based on the selected transmit hash policy. The default policy is a simple [(source MAC address XOR’d with destination MAC address) modulo slave count]. This mode provides load balancing and fault tolerance.
broadcast or 3 Transmits everything on all slave interfaces. This mode provides fault tolerance.
802.3ad or 4 Creates aggregation groups that share the same speed and duplex settings. Utilizes all slaves in the active aggregator according to the 802.3ad specification. Most network switches will require some type of configuration to enable 802.3ad mode.
balance-tlb or 5 Adaptive transmit load balancing: channel bonding that does not require any special switch support. The outgoing traffic is distributed according to the current load (computed relative to the speed) on each slave. Incoming traffic is received by the current slave. If the receiving slave fails, another slave takes over the MAC address of the failed receiving slave.
balance-alb or 6 Adaptive load balancing: includes balance-tlb plus receive load balancing (rlb) for IPV4 traffic, and does not require any special switch support. The receive load balancing is achieved by ARP negotiation.

[ Source: See Documentation/networking/bonding.txt for more information. ]