HOWTO:Bonding
From TIER
Contents |
Aim
To aggreate multiple network interfaces (wireless in our case) into a single logical interface.
Linux bonding driver
The Linux bonding driver provides a method for aggregating multiple network interfaces into a single logical bonded interface. The behavior of the bonded interfaces depends upon the mode; generally speaking, modes provide either hot standby or load balancing services.
Installation
Kernel config
Select "Bonding driver support" in the "Network device support" section.
User-level tools
The ifenslave user level control program is included in the kernel source tree, in the file Documentation/networking/ifenslave.c. It is generally recommended that you use the ifenslave that corresponds to the kernel that you are using (either from the same source tree or supplied with the distro).
Configuration
For manual configuration:
modprobe bonding mode=balance-rr modprobe <network-driver> ifconfig bond0 192.168.1.1 netmask 255.255.255.0 up ifenslave bond0 eth0 ifenslave bond0 eth1
For auto configuration: in /etc/network/interfaces
iface bond0 inet static
address 10.0.200.2
netmask 255.255.255.0
broadcast 10.0.200.255
up /extra/work/ifenslave bond0 wlan0 wlan1
down /extra/work/ifenslave -d bond0 wlan0 wlan1
down ifdown wlan0
down ifdown wlan1
down ifup wlan0
down ifup wlan1
For status:
$ cat /proc/net/bonding/bond0 $ ifenslave bond0
Interesting modes
balance-rr or 0
Round-robin policy: Transmit packets in sequential order from the first available slave through the last. This mode provides load balancing and fault tolerance.
balance-xor or 2
XOR policy: Transmit based on the selected transmit hash policy. The default policy is a simple
(source MAC address \oplus destination MAC address) % n_{slaves}
Alternate transmit policies may be selected via the xmit_hash_policy option. This mode provides load balancing and fault tolerance.
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.
Multiple links to increase throughput
Bonding mode for this type is balance-rr. Usual caveats about out of order packet delivery are mitigated by the use of network adapters that do not do any kind of packet coalescing
+-----------+
| Host A |
+-+---+---+-+
| | |
| | |
+-+---+---+-+
| Host B |
+-----------+
Configuration
- ifconfig of Host B. The MASTER puts the same MAC address on both the slaves.
bond0 Link encap:Ethernet HWaddr 00:00:24:C3:DF:44
inet addr:10.0.200.2 Bcast:10.255.255.255 Mask:255.255.255.0
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
eth3 Link encap:Ethernet HWaddr 00:00:24:C3:DF:44
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
eth4 Link encap:Ethernet HWaddr 00:00:24:C3:DF:44
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
- /proc/net/bonding/bond0 on Host B
Ethernet Channel Bonding Driver: v2.6.0 (January 14, 2004)
Bonding Mode: load balancing (round-robin) MII Status: up MII Polling Interval (ms): 0 Up Delay (ms): 0 Down Delay (ms): 0
Slave Interface: eth3 MII Status: up Link Failure Count: 0 Permanent HW addr: 00:00:24:c3:df:44
Slave Interface: eth4 MII Status: up Link Failure Count: 0 Permanent HW addr: 00:00:24:c3:df:45
Working
References
- Linux kernel bonding.txt : http://linux-net.osdl.org/index.php/Bonding
- About link aggregation: http://linux-ip.net/html/ether-bonding.html
- About balance-alb mode:
