4

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.

2

1 Answer 1

0
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.

You must log in to answer this question.

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