[Gllug] Load balancing source IPs

- Tethys tethys at gmail.com
Tue May 20 14:44:27 UTC 2008


I have a box with 16 IP addresses. I want outbound connections to a
particular destination to pick a random one of those 16 IP addresses
to use as a source IP for each new connection. I currently do this
with a simple iptables SNAT rule:

iptables -t nat -I POSTROUTING -d 10.0.8.1 -j SNAT --to 10.0.0.16-10.0.0.31

That works fine... on the existing CentOS 4 box. When trying to
migrate this to a newer box, it no longer works. The first connection
picks a random IP in the supplied range, and then all subsequent
connections use the same IP again. I'm guessing there's some cache of
src/dst IP pairs somewhere that's causing this behaviour[1]. Does
anyone know where it's doing this, and how I can turn it off? Or how I
can achieve the same effect by some other means?

In summary, it works fine with:

CentOS 4.4, kernel 2.6.9-42.0.10.ELsmp, iptables-1.2.11-3.1.RHEL4

On the other hand, it doesn't work with:

Fedora Core 5, kernel 2.6.18-1.2200.fc5, iptables-1.3.5-1.2
Ubuntu 7.10, kernel 2.6.22-14-server, iptables 1.3.6.0debian1-5ubuntu5

Any ideas?

Tet

[1] It doesn't seem related to the port number used -- it still reuses
the same source IP regardless of the destination port to which I'm
trying to connect.

-- 
Perl is like vise grips. You can do anything with it but it is the
wrong tool for every job. -- Bruce Eckel
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list