-1

I have a server with two main network interfaces and 5 virtual interfaces like this.

eth0 - 192.168.1.1
eth1 - 192.168.3.1

eth1:2 192.168.3.3
eth1:3 192.168.3.4
eth1:4 192.168.3.5
eth1:5 192.168.3.6
eth1:6 192.168.3.7

etho is my internal facing interface and eth1 is my external facing interface. I need to route all my traffic using all 5 network interfaces using round robin. if three request come to the eth0 those three requests go through the eth1:1 eth1:2 eth 1:3 respectively. order is not matter. i need to use all five interfaces active and routing my traffic using round robin. how Can I do this ? is it possible to do with iptables only ?

1 Answers1

2

I think you could do this using the PREROUTING chain with the statistic module. You can look at this article : Simple Stateful Load Balancer with iptables and NAT

In your case it could be something like :

iptables -t nat -A PREROUTING -i eth0 -m state --state NEW -m statistic --mode random
 --probability .25 -j DNAT --to 192.168.3.3

iptables -t nat -A PREROUTING -i eth0 -m state --state NEW -m statistic --mode random
 --probability .25 -j DNAT --to 192.168.3.4

iptables -t nat -A PREROUTING -i eth0 -m state --state NEW -m statistic --mode random
 --probability .25 -j DNAT --to 192.168.3.5

iptables -t nat -A PREROUTING -i eth0 -m state --state NEW -m statistic --mode random
 --probability .25 -j DNAT --to 192.168.3.6

It should work theoretically, but I can't assure you that this setup will work with stateful protocols

Another option could be to look for a solution such as HAPROXY

Esteban
  • 286
  • 1
  • 7