Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My PC has a total of 4 NICs, 2 wired Gigabit Ethernet network cards and also 2 wireless network cards. (One Broadcom with proprietary drivers and Ralink with open source software, which works much better than Broadcom.)

My cellphone can share its connection wirelessly to my PC, but I also have a wired Internet connection. So I have multiple Internet connections to access the Internet. How can I merge 2 or more connections together and balance them to enjoy one unified Internet experience that it is the sum of all Internet connections connected to it.

For example if I have a modem with an Internet connection of 1024kB/s and another one that offers 512kB/s and one small one that offers 128kB/s, after load balancing and merging all connections (Bonding or Teaming), I could download at a speed of 1664kB/s using all 3 Internet connections as one for example.

This question has always intrigued me.

share|improve this question
Seems rather beyond the scope of Ask Ubuntu :) This is pretty complex networking stuff. IMO it's rarely worth it, by the time you take into account lost packets due to a link being down (even temporarily), reordering packets due to some links being slower than others, and such things. I don't know of a "black box" solution that'll do this, could be an interesting project. – Caesium Nov 27 '11 at 17:43
Well the question is about if this can be done in ubuntu and if yes how. – Luis Alvarado Nov 27 '11 at 17:47
I created an answer in the 2 internet connections on a single PC post. Linking documents for bounding in Ubuntu. – Lucio Feb 25 '13 at 19:58
@Lucio I could mark the question as duplicate or you can move your answer here and I can mark it as accepted. You would also need to be ready for when 13.04 comes out since it will include in Network Manager the bonding options (Only wired bonding slaves right now). – Luis Alvarado Feb 25 '13 at 20:50
up vote 7 down vote accepted

I do something like that at work using Ubuntu 11.04. We run the Shorewall firewall configuration tool, which besides being excellent at its job, provides some rudimentary multiple ISP routing tools which might fit your needs. You can find some docs about it here: .

What it comes down to though, is you cant use multiple ISPs for a single connection... things are that simple. The best you can do is try to direct new connections evenly between the different providers.

It is a complex problem. You will probably end up beating your head against the wall (I certainly did) before you are done debugging every problem. So, as other posters have suggested, you might be wise to carefully consider how strong your desire is.

share|improve this answer
Nice link. Very nice tutorial. – Luis Alvarado Feb 8 '12 at 5:08
Let see also this:… – Postadelmaga Aug 31 '12 at 15:29

You could do it by using the package ifenslave that attaches and detaches slave network interfaces to a bonding device.

  1. Install:

    sudo apt-get install ifenslave
  2. Load bonding kernel module

    sudo modprobe bondingle
  3. Configure your interfaces:

    sudo vi /etc/network/interfaces

    Example config, to combine eth0 and eth1 as slaves to your bonding interface:

    #eth0 is manually configured, and slave to the "bond0" bonded NIC
    auto eth0
    iface eth0 inet manual
    bond-master bond0
    #eth1 ditto, thus creating a 2-link bond.
    auto eth1
    iface eth1 inet manual
    bond-master bond0
    # bond0 is the bonded NIC and can be used like any other normal NIC.
    # bond0 is configured using static network information.
    auto bond0
    iface bond0 inet static
    # bond0 uses standard IEEE 802.3ad LACP bonding protocol 
    bond-mode 802.3ad
    bond-miimon 100
    bond-lacp-rate 1
    bond-slaves none
  4. Restart Network:

    sudo restart networking
  5. Bringing up/down bounded interface:

    ifup bond0
    ifdown bond0

    There are several bonding modes as an example we use:

    bond-mode active-backup

    Description of active-backup bonding mode:

    Active-backup policy: Only one slave in the bond is active. A different slave becomes active if, and only if, the active slave fails. The bond's MAC address is externally visible on only one port (network adapter) to avoid confusing the switch. This mode provides fault tolerance. The primary option affects the behavior of this mode.

    Source and more info at the Ubuntu community help wiki.

Bonding, means combining several network interfaces (NICs) to a single link, providing either high-availability, load-balancing, maximum throughput, or a combination of these. Source

share|improve this answer
+1 because is one of the reasons for my question. Will still wait for a way to create a virtual network master connection that is the sum of all slave (real) connections. Something like bonding that comes in the latest kernel version. – Luis Alvarado Nov 26 '12 at 13:08
-1 - bonding works in LANs as it's operating at Layer 2. The question is about load balancing two independent WANs. – gertvdijk Dec 29 '12 at 12:33
@gertvdijk I don't agree check my update answer to find out that bonding does also load balancing. – pl1nk Dec 31 '12 at 14:33
@pl1nk This is Layer 2 load balancing for two NICs in the same L2 network. This is not the same as multi-ISP load balancing! – gertvdijk Dec 31 '12 at 14:50
@pl1nk My final comment. The question is concerning multiple independent broadband connections, clearly. While they may be one ISP, this does not change the disability to handle this at layer 2. – gertvdijk Dec 31 '12 at 15:10

It's a little bit old question, but if you still want to know..

There are 2 typical scenarios, what gertvdijk and pl1nk were arguing in one of the answers:

You have a computer with 2 public IPs (2 different ISPs) and you connect to another host (e.g. a server in a datacenter with a fat pipe that's bigger than the aggregate bandwidth of both ISP connections of your computer). So you establish a bonding connection to the host via your 2 connections and then the host (server) serves your traffic via its own internet connection. In this scenario, you can get almost 100% of the combined bandwidth in both directions for a single connection.

This is a particular case of bonding/teaming/ling aggregation where multiple layer 2 (same network) interfaces are joined together. It could be archived by establishing vpn layer 2 (tap) connections on each ISP interface from the computer to the host and bonding them together (round-robin mode) to have a single interface. The limiting factor in this scenario is how different are the delays (ping) on each ISP connection to the host. The more similar and stable they are, the better. We use it in one of our installations, it works well. If you would like to know the details about how to implement it just let me know.

Then another scenario would be without an intermediate host, i.e. a direct connection from you ISP interfaces to the webservers around the world. In this case the best you can get is to evenly distribute outgoing connections between the interfaces – i.e. one TCP session goes entirely via one ISP, a second session via another and so on. It is so because when you establish a TCP connection, it has an origin and a destination IPs for each packet and when a server receives a packet from another IP for which a TCP handshake was not performed, it considers the packet as erroneous and drops it. As each ISP connection has its own public IP, for the same TCP session you can't send one packet via one connection from one IP and another via another connection with another IP.

You won't get here as high aggregate bandwidth utilization for a single computer as with the first scenario, but for a small office it could be a good solution. What you can do to extend it a little bit is to implement custom solutions for specific protocols. For example you could have some sort of a proxy on the gateway (which could be the same computer) for http downloads and ask for different parts of a huge file establishing different TCP sessions via different ISP interfaces. In this case the resulting download rate would be near 100% of the combined bandwidth. It's like offloading to the gateway what ReGet, GetRight and similar downloaders do. Google for HTTP 206 Partial Content. I don’t know any out-of-the-box open-source solutions for this scenario, but there are hardware appliances that do exactly this: google for mushroom networks.

share|improve this answer
Wow! The first part of your answer is exactly what I am looking for. I have a server in the cloud with Ubuntu and a very fast connection. And the only internet connection I can have here is 300kbps with limited 3G. Can you give more information onhow to achieve the first part of your answer, so that I can buy many 3G dongles and plans to improve the speed of my connection? – Huafu Jun 1 '15 at 22:23
echo "bonding" >> /etc/modules echo -e "alias bond* bonding\noptions bonding max_bonds=10 mode=2 xmit_hash_policy=layer3+4 arp_interval=100 arp_ip_target=" > /etc/modprobe.d/bonding.conf – Anatoli Jun 3 '15 at 4:06
And enslave all the tap ifaces to this bond: echo "+tapX " >> /sys/class/net/bond0/bonding/slaves Check its state with: cat /proc/net/bonding/bond0 At this stage all internet traffic should flow via bond0 to the server in the datacenter. There you should set routing: echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf sysctl -p /etc/sysctl.conf iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE (eth0 is supposed to be the internet iface) – Anatoli Jun 3 '15 at 4:09
This bond configuration (mode=2 xmit_hash_policy=layer3+4) will make each new connection go via different underlying VPN iface based on the hash (calculated from the IPs and ports involved in the connection) mod iface number. More info: This actually is more like the second solution from my answer, it's because you need a very similar (very low jitter and same bandwidth) underlying connections for round-robin bonding to function correctly (otherwise you get a lot of packet reordering) and you say that your connections are 3G. – Anatoli Jun 3 '15 at 4:09
@Huafu, to have the first solution you just have to change the bonding options instead of mode=2 xmit_hash_policy=layer3+4 y specify mode=0 (see the link @, but first check how similar are the links via 3G. If their ping times differ more than 2-3ms or jitter is more than 1ms you'll have a lot of packet reordering effectively reducing the speed of the aggregated link. You'll have to check aggregated link statistics with netstat -s (look for retransmissions) and iperf -s / iperf -c <server_ip> -d. 1st check the performance of each link, then we can continue with a solution – Anatoli Jun 4 '15 at 16:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.