using iptables to change a destination port but keep the ip the same.

Posted by Scott Chamberlain on Server Fault See other posts from Server Fault or by Scott Chamberlain
Published on 2010-03-23T02:58:46Z Indexed on 2010/03/23 3:01 UTC
Read the original article Hit count: 325

Filed under:
|
|

I am playing around with transparent proxies, The current way I am doing things is the program makes a request to a computer on port 80, I use

iptables -t nat -A OUTPUT -p tcp --destination-port 80 -j REDIRECT --to-port 1234

to redirect to my proxy that I am playing with. the proxy will send out a request to port 81 (as all outbound port 80 are being fed back in to the proxy so I want to do something like

iptables -t nat -A OUTPUT -p tcp --destination-port 81 -j DNAT --to-destination xxxx:80

The problem lies with the xxxx part. How do I change the destination port without changing changing the destination ip? Or am I doing this setup completely wrong, I am learning after all and constructive criticism is definitely appreciated.

© Server Fault or respective owner

Related posts about iptables

Related posts about nat