Today I’ve been wondering how to loadbalance my home traffic accross two connexions. I had already done some load balancing but the solutions were only possible using a route-based algorithm so, no real gain from using such a method with a small used connexion. What I want to achieve today is sharing link by packet equally over two links.
+-------+ tap0 +-------+ | |==========| | 'home' ---| A | | B |---- 'Internet' | |==========| | +-------+ tap1 +-------+
The A Host is simply my gateway at home while the B one is a server hosted with a 100mbps link on internet. For this to work, we will establish two tunnel connection, one accross each connexion. This will not be covered by this howto. When you have your two tunnel working accross your two link, issue the following commands:
- tc qdisc add dev tap0 root teql0
- tc qdisc add dev tap1 root teql0
- ip link set dev teql0 up
- echo 0 > /proc/sys/net/ipv4/conf/eth1/rp_filter
- echo 0 > /proc/sys/net/ipv4/conf/eth2/rp_filter
Assign some ip range to both side of the tunnel and the teql0 interfaces:
On A:
# ip addr add dev tap0 10.0.0.0/31 # ip addr add dev tap1 10.0.0.2/31 # ip addr add dev teql0 10.0.0.4/31
On B:
# ip addr add dev tap0 10.0.0.1/31 # ip addr add dev tap1 10.0.0.3/31 # ip addr add dev teql0 10.0.0.5/31
And you’re set, just make a simple connection sharing on B and set the default route of A to go through teql0n interface.
With two VDSL connexions of 18mbps each, I’ve achived following results:
eth0 teql0 tap0 tap1 KB/s in KB/s out KB/s in KB/s out KB/s in KB/s out KB/s in KB/s out 2835.63 337.12 0.00 161.57 1367.10 94.97 1345.43 94.88 2820.16 320.10 0.00 159.19 1331.87 93.25 1341.88 93.53 2846.81 322.49 0.00 160.02 1358.17 94.10 1342.33 94.01 2802.83 330.04 0.00 157.97 1341.62 92.99 1318.91 92.81 2864.40 325.38 0.00 161.56 1348.64 94.87 1367.14 94.96