In my local area network I have two routers that provide internet connection using two different ISPs. I can choose which ISP to use by configuring the appropriate router as default gateway.

The internet connections are both asynchronous - both have lot's of downstream capacity and only little upstream capacity. Unfortunately I need plenty of traffic for uploading videos to Youtube. I want to use both internet connections simultaneously in order to speed up my Youtube uploads.

Many questions on serverfault link to this document which describes how to setup route based load balancing. But since most of my traffic goes to the same destination (Youtube) this won't help.

I imagine it should be quite simple to alternate sending packages over one or the other gateway. If all packages have the same IP adress as source address (meaning that incoming traffic will always use the same interface) there should be no problem, is there? The only show stopper I can think of is NAT which may keep me from setting the source IP adress. Unfortunately I have no ipv6 connection yet and have to live with NAT.

So questions:

  1. How can load balancing of outbound traffic be done (Linux)
  2. Can this be done while using NAT?
  • @RobbieMckennie: I did. I happen to have linked just this article in my question above and explained why I believe it won't help. – yankee May 26 '13 at 22:55

To be able to utilize the upload bandwidth from both your gateways you need to split the packets of the single upload connection to Youtube so that they will travel through both gateways, and then reassemble back into one connection to reach Youtube.

One way to do this is if your modem/router and your ISP support MLPPP. But since most ISPs do not provide this there is another way (less stable/robust though on asynchronous gateways with unstable latency).

You will need a VPS server with 2 public IPs.

From your router you set up 2 VPN connections to the VPS. Each connection will use each one of your gateways (hence the 2 public IPs on the VPS). This can be done with simple static routes so that each IP is routed through each gateway.

Then you do bonding on top of those 2 VPNs to create a single link between your router and the VPS.

You then configure your router to route all packets from your LAN/PC via the bonding interface.

On the VPS side, you have to configure SNAT in order for the packets from the bonding interface to go out on the internet.

A crude diagram would be like this:

                            ----- GATEWAY 1 -----
                           /                     \
                          /                       \
                          \                       /
                           \                     /
                            ------ GATEWAY 2 ----

I have implemented the above using MikroTik RouterOS but it can be done on Linux too (since MikroTik is also Linux based).

For the bonding to work on top of the VPNs you will either need to use OpenVPN or EoIP (Ethernet over IP tunnel).

The bonding driver will be configured in balance-rr mode (Round Robin mode) so that the packets of a single connection will be split amongst the 2 VPNs.

The NAT needed is a simple masquerade only on the VPS to allow packets from your LAN/PC to go out on the internet with the VPS IP.

  • +1. Did that for years with 2 connections to a data center. Has it's own issues - if a conneciton is down that must be found, rebalanced - but at the end that is the only solution. – TomTom May 26 '13 at 11:26
  • Shouldn't it be possible to do this without a VPN using the idea I described in the question? After all Youtube should not even know from which of the two connections my packets came from. (I only need to load balance outgoing traffic, incoming traffic is no problem). – yankee May 26 '13 at 22:59
  • You mean you want to utilize both gateways by uploading multiple videos at the same time? (hence multiple tcp connections?) – Cha0s May 26 '13 at 23:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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