Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am playing around with transparent proxies, unfortunately I do not have two machines to test it out with. 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.

The machine I am using is pretty low end so I would like not not have to create a VM with a second box unless absolutely necessary.

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

The answer I believe you're looking for sounds very similar to your first rule:

iptables -t nat -A OUTPUT -p tcp --destination-port 81 -j REDIRECT --to-port 80
share|improve this answer
    
Redirect changes the destination ip to your own box's ip –  Scott Chamberlain Mar 23 '10 at 13:08
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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