The PC I use has two network (ethernet) ports in the back. For years I’ve always had one cable plugged into it, leaving the second (RJ45) port unused. Recently however there’s been a second ISP provider added.
It got me thinking about the old days – When I was on dial-up and we used to “join” two modems together to improve our web surfing speed. This caused a spark as I realized that I could potentially increase my surfing speed by configuring both ethernet ports to appear as one connection (to my applications) – Meaning that the physical ports are combined to appear as one logical (interface) port to applications (such as Firefox, etc). I could also provide load balancing and fault tolerance to my PC’s network functions. Doing so would allow my PC (Ubuntu 8.04) to manage the connection, and my applications to enjoy the faster Internet speeds.
This logical interface provides more than one benefit:
Fault tolerance, if one port or network (WAN) fails, the other is still working. This occurs in a graceful manner so that you don’t have to tweak or configure settings when the failure occurs.
Load balancing, the OS will ensure that theres an even flow across both physical ethernet ports (via the single logical interface). The key benefit is that you can balance your traffic load between independent WAN networks (like 2 ISPs), even including other WiFi access points (used with the permission of the WiFi subscriber). You could even mix DLS, Cable or dial-up connections. (In my case it’s two different Cable networks I’m connecting to).
The common term for this is called port trunking or link aggregation. According to Wikipedia, this is defined as:
“…Link aggregation or IEEE 802.1AX-2008, is a computer networking term which describes using multiple network cables/ports in parallel to increase the link speed beyond the limits of any one single cable or port, and to increase the redundancy for higher availability…”

The Linux Foundation web site has a lengthy blurb about this because you have to make sure that your Linux kernel is compliled with the “bonding” module. From their site:
“…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. Additionally, link integrity monitoring may be performed…”
But don’t worry, most current Linux distributions have this. You’ll also need the ifenslave package. ifenslave is a tool to attach and detach slave network interfaces to your logical interface. Don’t forget that this logical (aggregated or “bonded”) interface will behave just like your normal single network connection would do, to the kernel. However, the load balancing will send data packets via the slave (physical) ports using a round-robin scheduler.
Before doing this though, MAKE SURE you have BACKUPS of any settings, configurations, files, etc. This way you are able to revert back to a working system in case something went wrong.
Again most current distributions should have ifenslave. If not it’s simple to install. Mine did not have it installed so the command to do this is:
sudo aptitude install ifenslave
I have two network cards on my system, called eth0 and eth1. After installing ifenslave using the above command, I need to take down both my network cards (so they are not in use). The command to do that was:
sudo ifdown eth0 && sudo ifdown eth1
Now we need to load the bonding module (we use “modprobe” to do that). Here’s the command to do that:
sudo modprobe bonding mode=0 miimon=100
As you can see, two switches are included with the command:
mode=0 specifies that round robin should be used. That way our data is alternated between the two network ports (and therefore routed through the two WANs – Which speeds up the Internet connection as you are now essentially being served through 2 ISP connections). This mode provides load balancing and fault tolerance. There are other modes, but you can tweak this later.
miimon=100 specifies how many milliseconds to wait between each check of the connections. The “check” is to see if the connection has failed. (100 is the default, but you can also change it later)
Now we have to aggregate the ports, in other words create the actual bond. To do this, we can create “bond0″ (that’s bond with a “zero” after it) using the following commands:
sudo ifconfig bond0 xxx.xxx.xxx.xxx (Use the correct IP address for your LAN! In other words, change xxx.xxx.xxx.xxx to an appropriate IP address inside your local area network- Usually that’s something like 192.168.1.10, as an example)
ifenslave bond0 eth0
ifenslave bond0 eth1
The above two commands connect physical port eth0 and eth1 to the virtual interface called bond0. Again, ifenslave is just the tool that tool to attaches and detaches slave network devices to a bonding interface.
Your done!
One important thing to keep in mind that connecting to two WANs does NOT double your connection speed! I noticed some speed increase however, so please do not think that this is a way to double your connection speed – It’s not! More importantly the fault tolerance is a bigger benefit for me. If something is not working through the one physical port, it will through the other.
For those interested in tweaking the modes (Google searching will help with that), but below is a basic outline of the other available modes:
mode 1 = Active backup. This keeps using one port (adapter) until it fails, then switches to the other one.
mode 2 = Balance XOR (“XOR” means “And Or”, tries to balance traffic by splitting up outgoing packets between the adapters, using the same adaptor for each specific destination when possible.
mode 3 = Broadcast mode. This simply sends out (transmits) all traffic on every interface. This is fault tolerant.
mode 4 = Dynamic link aggregation. This creates grouped adapters using an algorithm to aggregate adapters by their speed and other settings (those that use the same speed and settings).
mode 5 = Adaptive transmit load balancing. This redistributes outgoing traffic dynamically based on current conditions. In other words if one adaptor is overloaded, the traffic is transmitted through the other one.
mode 6 = Adaptive load balancing. This does the same as mode 5 but for inbound traffic.
I’m sure there are tons of “bonding” resources available, but I do hope that this helps some of you put that second ethernet port to good use. If anything, at the very least, is nothing else, I hope it’s a good exercise to become more familiar with Linux, Linux commands and system configuration.

Pingback: HowtoMatrix » How to Use the Second Network Port on Your Computer
I’ve read many howto about nic bonding, but all fail when in ubuntu 9.04. Command update-modules and config files are no longer present.
You do not mention editing /etc/network/interface file.
This Tutorial is enough to keep nic bonding working after a server reset?
tks
Laercio
@laercio
This is for Ubuntu 8.04 not 9.04 – I don’t have 9.04 installed because it is not LTS
So… I’m not yet sure how this will work with 9.04
tks, anyway!
I’ll keep on trying.
But if u hear anything about how to make nic bonding working with 9.04 server (walking on the street, lintening to the radio, wherever..) I will appreciate if u let me know.
Laercio
You claim that eth0 and eth1 are hooked to cable modems, the interfaces would have public IPs.
Then you say:
sudo ifconfig bond0 xxx.xxx.xxx.xxx (Use the correct IP address for your LAN! In other words, change xxx.xxx.xxx.xxx to an appropriate IP address inside your local area network- Usually that’s something like 192.168.1.10, as an example)
What LAN are you talking about? Do you have a eth2 that goes to your LAN or something? Did you even get this working? Seems incomplete and vague.
Hello, I’ve been working to connect two USB modems of different ISPs to my linux machine and I’ll try doing this workaround. However, I am confused of what IP address to use in bond0. Please help me with this one.. really urgent. Thanks
The “bond0″ interface should be an address accessible to your machines, i.e. on your local network, give it a local IP and use that IP for the gateway for all others.
Good idea, and works.
Now to figure out how to stop Network manager from starting my interfaces automatically and make bond0 come up.
You should include the interfaces file for auto startup.
Hi,
I am a newcomer to the world of Linux from windows,attracted by its simplicity and my requirement.
I am interested in wireless USB 3g/4g bonding 4 units to get aggregation of Bandwidth which I want to obtain using my laptop.The laptop has at least 4 USB ports which is sufficient for the USB wireless modems.Going through google I come to understand that it is possible with Linux,to bond multiple Wireless broadband without any add on device.Kindly any one help me.I want to stream live video from remote location with 3g or EVDO.
Thanks in Advance.
Great information source here, but I must echo the confusion of prior posters. I, for instance, am trying to enslave wired connection eth0 and wireless connection wlan0. Both exist on separate, independent LANs. How can you then do this:
sudo ifconfig bond0 xxx.xxx.xxx.xxx
with the “correct IP address for your LAN” when there is no IP address that is common to both LANs?
Pingback: Netzwork "bridges"
this tutorial is for computer with two nic, right?
i have a laptop, but i have two connection one is ethernet, the other is usb modem
can i combine this two connection on my laptop?
@joko
You probably can (although I have never tried that).