Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I connect thought tunnel to other machine like this: ssh user@ip -L2000:

So on my local machine I want to configure iptables that way like I have a "native" access to address. I mean when I enter on web browser http:// iptables will redirect to my localhost port 2000 which is connected to remote machine.

How can I configure iptables to redirect from port 80 to localhost port 2000?

I tried this but with no luck:

sudo iptables -t nat -A PREROUTING -p tcp -d --dport 80 -j DNAT --to-destination

On mac os x machine I do it like this:

sudo ifconfig lo0 alias
sudo ipfw add fwd,2000 tcp from me to dst-port 80

But I don't know how to do this on linux machine.

share|improve this question
related… – tair Mar 17 '13 at 11:33
I guess I miss something like "alias" – Yoldar-Zi Mar 18 '13 at 4:40
iptables -t nat -I PREROUTING -p tcp -d --dport 80 -j DNAT --to-destination

IE your command was pretty much correct. I'm guessing another rule is being matched first so this rule is never being hit. Using -I instead of -A puts this rule at the beginning rather then end of the table.

share|improve this answer

Your Answer


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.