I have two different ISPs. I want to set some kind of load balancing setup that will distribute packets to those providers. I know this can be done using different routing tables, but I wanted to use something called "multipath gateway".
I've configured both interfaces in the
/etc/network/interfaces file. Both of the connections work separately. I replaced the default gateways with the one below:
# ip route add default \ nexthop via 192.168.1.1 dev bond0 weight 1 \ nexthop via 10.143.105.17 dev wwan0 weight 1
I added masquerade targets in
iptables on both of the interfaces:
iptables -t nat -A POSTROUTING -o wwan0 -j MASQUERADE iptables -t nat -A POSTROUTING -o bond0 -j MASQUERADE
Also I enabled (partially) reverse path filtering via
net.ipv4.conf.all.rp_filter = 2 net.ipv4.conf.default.rp_filter = 2
This setup works. Packets (connections) are sent via both interfaces. There's just one problem I don't get.
When I want to check my IP address using the following commands:
$ curl text.whatisyourip.org $ curl eko.one.pl/host.php
The IP address is different in both cases, which means that the mechanism works well. Also I can see it working in
wireshark. But when I'm trying to send, for instance, multiple requests to the first of the domains above, I always get the same IP address in response. So it looks like that packets that are destined to the specific IP address always go through the same interface. I'm just wondering why. Is there any mechanism that remembers the destination IP addresses of the previous requests and makes the next requests to the same addresses to go through the same interface?