LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Can iptables be used to load balance incoming traffic b/w L4 ports? (https://www.linuxquestions.org/questions/linux-newbie-8/can-iptables-be-used-to-load-balance-incoming-traffic-b-w-l4-ports-4175706106/)

aaa847 01-09-2022 11:35 AM

Can iptables be used to load balance incoming traffic b/w L4 ports?
 
Hello Guys,

We have an application that can be initialized to listen for incoming udp traffic at any L4 port like 9997 or 9998 etc. We are receiving traffic at the server side (hosting the instances of the application) on port 9996 however if we run a single instance of the application listening on port 9996 to handle all this traffic we run into stability issues, we require to divide incoming traffic on port 9996 among ports 9997, 9998 and 9999 etc (a separate instance of the application will be listening on these ports) equally. I was wondering if we can use iptables as a L4 load-balancer for achieving this? Any help in this regard would be much appreciated.

PFB iptable config at server side:

Chain PREROUTING (policy ACCEPT)
num target prot opt source destination

Chain INPUT (policy ACCEPT)
num target prot opt source destination

Chain OUTPUT (policy ACCEPT)
num target prot opt source destination

Chain POSTROUTING (policy ACCEPT)
num target prot opt source destination


Regards,
aaa847

uteck 01-10-2022 08:46 PM

I am not sure if iptables supports the logic to do this intelligently. Take a look at this page using Nginx as a load balancer to get some ideas.
https://docs.nginx.com/nginx/admin-g...load-balancer/

beka 01-12-2022 02:05 AM

I don't think iptables is suitable for this purpose. You can look into HAProxy - Apache and Nginx can also serve to load balance when configured as reverse proxy servers.

Best


All times are GMT -5. The time now is 06:42 PM.