Hello all,
I have been playing with an IPtables load balancer I found from this blog:
https://www.webair.com/community/sim...ables-and-nat/
Anyhow, this guy created a load balancer where he can at the gateway filter packet by packet and evenly distribute packets to any set of targets. So the code basically looks like the below and I can confirm the idea does work.
Code:
iptables -t nat -A PREROUTING -p tcp -i eth0 --dport 80 -m state --state NEW -m statistic --mode nth --every 4 --packet 0 -j DNAT --to-destination 10.0.0.3:80
# iptables -t nat -A PREROUTING -p tcp -i eth0 --dport 80 -m state --state NEW -m statistic --mode nth --every 4 --packet 1 -j DNAT --to-destination 10.0.0.4:80
# iptables -t nat -A PREROUTING -p tcp -i eth0 --dport 80 -m state --state NEW -m statistic --mode nth --every 4 --packet 2 -j DNAT --to-destination 10.0.0.5:80
# iptables -t nat -A PREROUTING -p tcp -i eth0 --dport 80 -m state --state NEW -m statistic --mode nth --every 4 --packet 3 -j DNAT --to-destination 10.0.0.6:80
So my question is now I have been playing around with this idea in different ways trying to make this concept stateful which I have had no luck so does anyone have any ideas? My thoughts are I cannot use the statistics module because it appears to only filter by packet and I need something that will filter by connection so hopefully someone might have some ideas as this must be possible.
Thanks in advance,
Joe