NIC Bonding
If you have two or more network ports in your motherboard, and you’d like to make use of them, bonding (not bondage :p) is the answer.
Bonding provides multiple options, like maximizing throughput or redundancy. This is done by joining multiple Network Card Interfaces (NICs) and instead of addressing them by their physical interface name (e.g. eth0), a virtual interface name is created (e.g. bond0).
In our setup, we had a motherboard with a built-in 100Mbps network port. I had bought a USB-to-ethernet network dongle, which is also at 100Mbps. So, we thought of trying bonding out and see how much we can squeeze out of Adam.
All the guides online asks you to compile some modules and/or tweak the kernel. This is not necessary in our case, since everything worked out of the box when using Ubuntu Server (version 7.10).
If you do need the full details, then take a look at the sources’ links at the end of the page.
If you don’t know which version you have, login to the machine, open the shell/terminal and type:
cat /etc/issue
All our steps are done in the shell, so keep it open and learn some command line interface stuff ;)
1) You need to install a program called “ifenslave” which will enslave physical interfaces to a virtual one:
# sudo apt-get update && sudo apt-get install ifenslave
2) Append the following to the respective files:
# sudo nano /etc/modprobe.d/aliases
# bonding config — added manually — adam
alias bond0 bonding
alias eth0 e100
alias eth1 e100
options bonding mode=0
Bonding on Linux has many modes. We used mode zero, also known as round robin. It sends the packets in a sequential matter starting from the first available slave throughout the last. This provides throughput and redundancy. This means that if one of the slaves die, it should not render your machine inaccessible. For a list of all other available types, check out the sources linked.
# sudo nano /etc/modprobe.d/arch/i386
# bonding config — added manually – adam
alias bond0 bonding
options bonding mode=0
Next is the interfaces config: everything inside is commented out, except the stuff below (do not just append!!!!)
# sudo nano /etc/network/interfaces
# The loopback network interface
auto lo
iface lo inet loopback# The primary network interface
auto bond0
#iface eth0 inet dhcp#configure bonding
iface bond0 inet static
address 192.168.1.253
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
dns-nameservers 192.168.1.1
post-up ifenslave bond0 eth1 eth0
post-down ifenslave -d bond0 eth1 eth0
Make sure you change the IP addresses to match your network settings.
That’s it! You could restart your network daemon for the settings to take place, but we had many problems with that, and if you look at the sources, you’d notice that we didn’t include the option “miimon=100″ — since it caused some kernel panics and weird stuff.
While writing this page, I was connected to Adam’s shell, one cable was removed by accident, but the connection never dropped. This proves the redundancy part!
As for the throughput part, we had 2x 100Mbps ports configured, so theoretically we should’ve got 200Mbps, but we got 240Mbps!!
Sources:
http://www.howtoforge.com/nic_bonding
http://www.howtoforge.com/network_bonding_ubuntu_6.10
http://www.kernel.org/pub/linux/kernel/people/marcelo/linux-2.4/Documentation/networking/bonding.txt
