I have 3 machines: Router Server Client

on the server there is a TCP file server running on port 1234. I want to redirect all the client-server-client traffic via the router machine. Using iptables I was able to do some redirection. The client send the request and it redirect it to the router but the server answer directly to the client.

Those are the commands: On the client

 iptables -t nat -A OUTPUT -p tcp --dport 1234 -j DNAT --to-destination

On the router:

iptables -t nat -A PREROUTING -p tcp --dport 1234 -j DNAT --to-destination

What should be the command to run on the server?


I think all you are missing is on the router:

iptables -t nat -A POSTROUTING -j MASQUERADE

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.