2014-06-23

Network Interface Bonding

Linux.com :: What can you do with a second Ethernet port?: "To bond two Ethernet interfaces, you must have the bonding module compiled for your kernel (which on a modern distro is almost a certainty), and the ifenslave package (which is a standard utility, although you might need to install it from from your distro's RPM or APT repository)."
'via Blog this'
On a typical two-port motherboard, the Ethernet adapters are named eth0 and eth1, so we will use that for our example commands.
With ifenslave installed, take both Ethernet adapters offline by running
sudo ifdown eth0
sudo ifdown eth1.
Load the bonding module into the Linux kernel with modprobe. There are two important options to pass to the module: mode and miimon.  Mode establishes the type of bond (round-robin, failover, and so on), and miimon establishes how often (in milliseconds) the links will be checked for failure.
sudo modprobe bonding mode=0 miimon=100
will set up a round-robin configuration in which network packets alternate between the Ethernet adapters as they are sent out.
The miimon value of 100 is a standard place to begin; you can adjust if it you really want to tweak your network.
To create an actual bond (which for convenience we'll call bond0), run
sudo ifconfig bond0 192.168.1.100 up
to assign an IP address to the bond, then run
ifenslave bond0 eth0
followed by
ifenslave bond0 eth1
to tie the physical Ethernet interfaces into it.
Round-robin mode is good for general purpose load balancing between the adapters, and if one of them fails, the link will stay active via the other.
The other six mode options provide features for different setups.
  • Mode 1::  active backup, uses just one adapter until it fails, then switches to the other.
  • Mode 2::  balance XOR, tries to balance traffic by splitting up outgoing packets between the adapters, using the same one for each specific destination when possible.
  • Mode 3::  broadcast, sends out all traffic on every interface.
  • Mode 4::  dynamic link aggregation, uses a complex algorithm to aggregate adapters by speed and other settings.
  • Mode 5::  adaptive transmit load balancing, redistributes outgoing traffic on the fly based on current conditions.
  • Mode 6::  adaptive load balancing, does the same thing, but attempts to redistribute incoming traffic as well by sending out ARP updates.
The latter, complex modes are probably unnecessary for home use. If you have a lot of network traffic you are looking to manage, consult the bonding driver documentation. For most folks, bonding's fault tolerance and failover is a bigger gain than any increased link speed. For example, bonding two WAN links gives you load balancing and fault tolerance between them, but it does not double your upstream throughput, since each connection (such as a Web page HTTP request) has to take one or the other route.