Re:Abusing Linux's firewall: the hack that allowed us to bui...
by majke on Friday April 13, 2018 @05:39AM
(#16828360)
We have a single Accept queue for all the ports. For TCP it doesn't create any problems - the new connection rate is rarely significant.
For the accept-queue load balancing see these blog posts:
https://blog.cloudflare.com/the-sad-state-of-linux-socket-ba...
https://blog.cloudflare.com/syn-packet-handling-in-the-wild/
Ex. # TPROXY directs all traffic to :1234, and these rules load balance to 4 different processes
iptables -t nat -I OUTPUT -p tcp -o lo --dport 1234 -m state --state NEW -m statistic --mode nth --every 4 --packet 0 -j DNAT --to-destination 127.0.0.1:8080
iptables -t nat -I OUTPUT -p tcp -o lo --dport 1234 -m state --state NEW -m statistic --mode nth --every 4 --packet 1 -j DNAT --to-destination 127.0.0.1:8081
iptables -t nat -I OUTPUT -p tcp -o lo --dport 1234 -m state --state NEW -m statistic --mode nth --every 4 --packet 2 -j DNAT --to-destination 127.0.0.1:8082
iptables -t nat -I OUTPUT -p tcp -o lo --dport 1234 -m state --state NEW -m statistic --mode nth --every 4 --packet 3 -j DNAT --to-destination 127.0.0.1:8083