-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 ?

0

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

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.