How to merge multiple Internet connections into one?

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: http://www.shorewall.net/MultiISP.html

What it comes down to though, is you can't use multiple ISPs for a single connection... things aren't 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.


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
    address 192.168.1.10
    gateway 192.168.1.1
    netmask 255.255.255.0
    # 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.

    • Description of all bonding modes.

    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


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 achieved 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 your ISP interfaces to various 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 origin and destination IP addresses 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 achieve 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 '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 'mushroom networks'.