consider this scenario:
PC1 wants to telnet to SRV1 tcp 40000.
I would like to put a proxy in the middle that receives the connection, rewrites the destination, sends packet to a local socks proxy (redsocks).
So the scenario would be:
PC1 --> PROXY tcp 20000 [iptables rewrites destination to SRV tcp 40000 --> redsocks 127.0.0.1 tcp 12345] --> SRV1 tcp 40000
I tried:
iptables -t nat -A PREROUTING -p tcp -s $MYSOURCEIP --dport 20000 -j DNAT --to $SRV1:40000
It works, but I know it doesn't go through redsocks. I just changed the destination for the packets but how can I force them to flow into redsocks?