Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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:192.168.64.88:80

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

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

I tried this but with no luck:

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

On mac os x machine I do it like this:

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

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

share|improve this question
    
related serverfault.com/questions/140622/… – 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 192.168.64.88 --dport 80 -j DNAT --to-destination 127.0.0.1:2000

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .