I need to do port forwarding on my Linux (Debian 8
) to intercept packets going through the machine.
It needs to be based on source IP, so different ports for different IPs.
I've though of using iptables
ex.
iptables -t nat -A PREROUTING -s 10.1.10.78/32 -j REDIRECT --to-port 4321
iptables -t nat -A PREROUTING -s 10.1.10.31/32 -j REDIRECT --to-port 4444
iptables -t nat -A PREROUTING -s 10.1.10.79/32 -j REDIRECT --to-port 4321
iptables -t nat -A PREROUTING -s 10.1.10.21/32 -j REDIRECT --to-port 5000
But it seems going over 20K+ rules the machine becomes to slow, and iptables might need be the right solution.
I now I can scale the machine up, but are there a better solution other than iptables
for this "simple" challenge?