Increase your bandwidth through Ethernet bonding

When your server's hacking and wheezing, in desperate need of more bandwidth, what do you do? One cost-effective way to eke out more bandwidth is Ethernet bonding. Jim McIntyre explains how to rev up your Linux servers.

Ethernet bonding is a cost-effective way to increase bandwidth and maximize resources for critical Linux servers, such as firewalls and production servers. When Ethernet bonding is used, the bandwidth from two network interface cards (NICs) is combined, thus increasing the amount of bandwidth available for data transfers. Ethernet bonding can also be used on hot-swappable systems so that when one of the NICs fails, it can be replaced without removing access to the server or shutting the system down. In this way, Ethernet bonding can also provide fault tolerance. So what do you have to do to implement Ethernet bonding on your Linux server? The process can be completed in five relatively simple steps.

What you need
To implement Ethernet bonding, you need to have:
  • ·        Knowledge of Linux kernel compilation. For more information, see Jack Wallen, Jr.’s "Compiling (or recompiling) your Linux kernel."
  • ·        Source code for a Linux kernel newer than 2.2.17, which can be located on your distribution CD.
  • ·        A copy of ifenslave. (On new Linux releases, ifenslave may already be installed. For this article, RedHat 7.2 was used, and ifenslave was part of the default installation.)
  • ·        Two or more NICs.

Once you have the required hardware and software, you're ready to begin the five-step Ethernet bonding process.

Step one: Install the NICs
You must first install your network cards. When you select your networking hardware, remember to use two cards capable of the same transfer rates. A 10-Mb card doesn't offer much improvement when it’s bonded to a 100-Mb NIC.

If you can afford them, there are some dual-port NICs, such as theCompaq NC3122 Dual Port Fast Ethernet NIC, that are well suited for Ethernet bonding. These cards use two controllers, each controller being assigned a separate IRQ and I/O address.

If you use a recent Linux distribution, then you should only have to install the NIC and reboot your system. The new hardware should be detected automatically. If the second NIC isn't detected, add the following line to /etc/lilo.conf:

Then, as root, run the /sbin/lilo command.

All you need do then is reboot the system, and the new NIC should be detected. Once both NICs have been detected, connect both cards to the network and ensure that both cards have acceptable IP addresses. Run the following commands to ensure that both NICs are able to ping your network gateway. In this example, the IP address of the gateway is
/sbin/ifconfig eth0 up
ping -c 3
/sbin/ifconfig eth0 down
/sbin/ifconfig eth1 up
ping -c 3
/sbin/ifconfig eth0 up

If the ping requests are returned for each NIC, the cards are installed and operating properly.

Step two: Compile kernel support
To compile kernel support for Ethernet bonding, run the following commands as root:
cd /usr/src/Linux-<kernel-version>
make menuconfig, make config, or make xconfig

When your kernel compilation options are available, go to the Network Device Support menu and, under Bonding Driver Support, select module (m).

Compile as module
Although bonding support may be compiled into the kernel, Ethernet bonding works best when compiled as a module. Linux systems often become sluggish when bonding support is compiled directly into the kernel.

Once you have selected module (m) support for Bonding Driver Support, save your changes. Next, run the following commands as root:
make dep
make modules
make modules_install

After that, you'll need to create the bonding interface from the Ethernet bonding module.

Step three: Creating the bonding interface
To create the Ethernet bonding interface, edit the /etc/modules.conf file in any text editor and add the following line:
alias bond0 bonding

Ensure this device is loaded when the system is booted. Reboot the system and you're ready for step four.

Step four: Configuring the Ethernet Bonding Interface
Once the system is rebooted, you’ll see three network interfaces when you run the /sbin/ifconfig command without switches:
  • ·        eth0—The first network card installed
  • ·        eth1—The second NIC installed
  • ·        bond0—The bonding device created by the entry in /etc/modules.conf

The bonding interface must be configured with the same IP address and MAC address as eth0. To do this, first run the following command as root:
/sbin/ifconfig eth0

You should get results similar to this.

From this output, we get the IP address ( and MAC, or hardware, address (00:D0:B7:73:41:A7) for eth0.

Next, configure the bonding device, bond0, with the same IP and hardware addresses as eth0, using this command:
/sbin/ifconfig bond0 hw ether 00:D0:B7:73:41:A7

The next step is to use the ifenslave command to attach eth0 and eth1 to the bonding interface.

Step five: Attach the NICs to the bonding device
The next step is to attach the two network interfaces to the bonding device using the /sbin/ifenslave command. If your distribution includes ifenslave, you’ll probably find it in /sbin. If ifenslave is not on your system, download the source code from the ifenslave  Web site.

Once you have the code, run the following command as root to compile the program:
gcc -o ifenslave ifenslave.c

When ifenslave is compiled, copy the binary to /sbin or to whichever directory you would like to run it from.

The ifenslave command uses this format:
/sbin/./ifenslave <master-device> <slave-device> <slave-device>…

>= 2 NICs
For this article, I’m using two NICs. However, the ifenslave command allows the use of three or more network cards.

To bond both NICs to the bonding device, run the following two commands as root:
/sbin/./ifenslave bind0 eth0 eth1

To make sure that both NICS are now attached to the bonding device, run the /sbin/./ifenslave command, which will return output similar to this.

Note that the bonding device, eth1, and eth0 have all been assigned the same IP addressing and hardware address information, which is the original configuration for eth0.

If one of the interfaces attached to the bonding device fails, run the following command to deactivate the faulty card:
/sbin/./ifenslave –d bond0 eth1

To bring the bonding device down and release all interfaces attached to it, use this command:
/sbin/./ifconfig bond0 down

Step six: Test the configuration
To test the new configuration, perform a data transfer across the network and monitor the transfer rate with a network monitoring application (such as IPTraf). If your bonding device is running as expected, the load on the bonding should be equal to the combined bandwidth from both NICs. If one of the NICs isn't operating as expected, you may have to configure your switch or router to accept Ethernet bonding.

By following these five simple steps, you can set up Ethernet bonding and increase the bandwidth for your Linux servers. Doing so can provide much needed performance increases for e-commerce servers and firewalls. Since bandwidth is often the greatest bottleneck to system performance, this process might be just the answer to your Linux administration woes.

Editor's Picks