9

I have two ISP at the time, connected to the same machine. I added both of them in the routing table as default. However, only one connection is used.

$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    303    0        0 eth0
0.0.0.0         192.168.0.1     0.0.0.0         UG    303    0        0 eth1
192.168.1.0     0.0.0.0         255.255.255.0   U     303    0        0 eth0
192.168.0.0     0.0.0.0         255.255.255.0   U     303    0        0 eth1

How can I balance the traffic load between the two ISP?

2 Answers 2

9

The Linux Advanced Routing & Traffic Control HOWTO has a section describing to solve the problem.

The key step to balance traffic between the two routes is to give them both a weight.

ip route add default scope global \
    nexthop via 192.168.0.1 dev eth1 weight 1 \
    nexthop via 192.168.1.1 dev eth0 weight 1
3
  • The two endpoints of those routes are obviously using NAT. If he balances the traffic between the routes, it will break horribly as each gateway receives traffic for NAT entries it does not know or understand. Commented Nov 3, 2011 at 0:05
  • 1
    from what I understand, the routes are cached, requests for e.g. www.google.com will always go through the same endpoint.
    – bbaja42
    Commented Nov 3, 2011 at 8:33
  • Starting from linux 3.6 routes are not cached anymore, all caching code was removed for IPv4: kernelnewbies.org/Linux_3.6#Networking . So this solution for multihomed can't work anymore as-is.
    – A.B
    Commented Feb 22, 2020 at 12:40
0

Starting from linux 3.6 routes are not cached anymore, all caching code was removed for IPv4. So this solution for multihomed can't work anymore as-is.

This is right on stretch

~$ uname -a
Linux 4.9.0-12-amd64 #1 SMP Debian 4.9.210-1 (2020-01-20) x86_64 GNU/Linux

but jessie works

~$ uname -a
Linux 3.16.0-10-amd64 #1 SMP Debian 3.16.81-1 (2020-01-17) x86_64 GNU/Linux

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .