I want to forward requests from 192.168.99.100:80
to 127.0.0.1:8000
. This is how I'd do it in linux using iptables
:
iptables -t nat -A OUTPUT -p tcp --dport 80 -d 192.168.99.100 -j DNAT --to-destination 127.0.0.1:8000
How do I do the same thing in MacOS X? I tried out a combination of ipfw
commands without much success:
ipfw add fwd 127.0.0.1,8000 tcp from any to 192.168.99.100 80
(Success for me is pointing a browser at http://192.168.99.100
and getting a response back from a development server that I have running on localhost:8000
)
Best Answer
So I found out a way to do this. I'm not sure if it's the preferred way but it works! At your favourite shell:
(The alias to
lo0
seems to be the missing part)If you'd like a (fake) domain to point to this new alias then make sure /etc/hosts contains the line: