Linux NIC Teaming

What is bonding?
Bonding is the same as port trunking. In the following I will use the word bonding because practically we will bond interfaces as one.

But still...what is bonding?
Bonding allows you to aggregate multiple ports into a single group, effectively combining the bandwidth into a single connection. Bonding also allows you to create multi-gigabit pipes to transport traffic through the highest traffic areas of your network. For example, you can aggregate three megabits ports (1 mb each) into a three-megabits trunk port. That is equivalent with having one interface with three megabits speed.

mode=0 (balance-rr)
Round-robin policy: Transmit packets in sequential order from the first available slave through the last. This mode provides load balancing and fault tolerance.

mode=1 (active-backup)
Active-backup policy: Only one slave in the bond is active. A different slave becomes active if, and only if, the active slave fails. The bond's MAC address is externally visible on only one port (network adapter) to avoid confusing the switch. This mode provides fault tolerance. The primary option affects the behavior of this mode.

mode=2 (balance-xor)
XOR policy: Transmit based on [(source MAC address XOR'd with destination MAC address) modulo slave count]. This selects the same slave for each destination MAC address. This mode provides load balancing and fault tolerance.

mode=3 (broadcast)
Broadcast policy: transmits everything on all slave interfaces. This mode provides fault tolerance.

mode=4 (802.3ad)
IEEE 802.3ad Dynamic link aggregation. Creates aggregation groups that share the same speed and duplex settings. Utilizes all slaves in the active aggregator according to the 802.3ad specification.

	Pre-requisites:
1. Ethtool support in the base drivers for retrieving
the speed and duplex of each slave.
2. A switch that supports IEEE 802.3ad Dynamic link
aggregation.
Most switches will require some type of configuration
to enable 802.3ad mode.

mode=5 (balance-tlb)
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.

	Prerequisite:
Ethtool support in the base drivers for retrieving the
speed of each slave.

mode=6 (balance-alb)
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. The bonding driver intercepts the ARP Replies sent by the local system on their way out and overwrites the source hardware address with the unique hardware address of one of the slaves in the bond such that different peers use different hardware addresses for the server

Setup Bonding Ethernet on Debian and ubuntu with a 2.6 kernel

Xen64net:~# apt-get update && apt-get install ifenslave

Xen64net:~# mii-tool

eth0: negotiated 100baseTx-FD, link ok

eth1: negotiated 100baseTx-FD, link ok

Xen64net:~# cat /etc/modprobe.d/arch/i386

alias parport_lowlevel parport_pc

alias binfmt-0064 binfmt_aout

alias binfmt-332 iBCS

alias bond0 bonding

#alias bond1 bonding

#options bond0 mode=2 miimon=100 downdelay=200 updelay=200

#options bond1 mode=2 miimon=100 downdelay=200 updelay=200

options bonding mode=2 miimon=100 downdelay=200 updelay=200

Xen64net:~# cat /etc/modutils/actions

probeall bond0 eth2 eth3 bonding

#probeall bond1 eth1 eth0 bonding

Xen64net:~# update-modules

Xen64net:~# cat /etc/network/interfaces

#auto lo

#iface lo inet loopback

allow-hotplug eth2 eth3

auto bond0

iface bond0 inet static

address 192.168.12.20

netmask 255.255.255.128

hwaddress ether 00:02:B3:48:50:2C

network 192.168.12..0

broadcast 192.168.12.127

up ifenslave bond0 eth2 eth3

down ifenslave -d bond0 eth2 eth3

Xen64net:~#modprobe bonding

Xen64net:~#reboot

Xen64net:~# less /proc/net/bonding/bond0

Ethernet Channel Bonding Driver: v3.0.3 (March 23, 2006)

Bonding Mode: load balancing (xor)

Transmit Hash Policy: layer2 (0)

MII Status: up

MII Polling Interval (ms): 100

Up Delay (ms): 200

Down Delay (ms): 200

Slave Interface: eth3

MII Status: up

Link Failure Count: 1

Permanent HW addr: 00:1f:29:e8:b5:ee

Slave Interface: eth2

MII Status: up

Link Failure Count: 1

Permanent HW addr: 00:1f:29:e8:b5:f0

/proc/net/bonding/bond0 (END) Xen64net

Setup Bonding Ethernet on Debian and ubuntu with a 2.4 kernel

add the following lines to your /etc/modutils/arch/i386:

alias bond0 bonding

options bonding mode=1 miimon=100 downdelay=200 updelay=200

Xen64net:~# cat /etc/modutils/actions

probeall bond0 eth2 eth3 bonding

CentOS

In the /etc/modprobe.conf file add the following:

alias bond0 bonding
options bond0 miimon=80 mode=5

In the /etc/sysconfig/network-scripts/ directory create ifcfg-bond0:

DEVICE=bond0
IPADDR=<ip address>
NETMASK=
NETWORK=
BROADCAST=
GATEWAY=
ONBOOT=yes
BOOTPROTO=none
USERCTL=no

Change the ifcfg-eth0 to:

DEVICE=eth0
ONBOOT=yes
BOOTPROTO=none
USERCTL=no
MASTER=bond0
SLAVE=yes

Change the ifcfg-eth1 to:

DEVICE=eth1
ONBOOT=yes
BOOTPROTO=none
USERCTL=no
MASTER=bond0
SLAVE=yes

source: http://www.linuxhorizon.ro/bonding.html

http://anothersysadmin.wordpress.com/2007/10/02/ethernet-bonding-in-debian/