Search code examples
http-redirectiptablesnatturn

How to redirect and load balance locally generated packets through iptables?


Here is the scenario I am working on.

I have sslh listening on 443 which redirects https traffic to 445 and TURN traffic to 3478. I also have 6 TURN servers listening on 3478 to 3483. I wish to load balance the incoming TURN traffic across all these ports. I tried load balancing through the PREROUTING chain of the nat table but it didnt work since sslh is a local process and packets generated form it skips the PREROUTING table. I can see these packets coming from sslh in the OUTPUT chain of the nat table but I am unable to redirect them to another port.

Here is the rule i am using.

iptables -t nat -A OUTPUT -p tcp -o lo --dport 3478 -j REDIRECT --to-ports 3479

which is not working. Any help is highly appreciated!


Solution

  • I missed to add the transparency rules for sslh. After adding these rules,I was able to redirect the packets to a different ports