Search code examples
macosipiptablesmacos-sierra

Redirect port and ip on macOS


I'm working on a mac with OS 10.13.6.

I want to redirect all requests to 10.20.154.24:1111 made from my computer go to localhost:8080.

I read about pf and pfctl, but could not make this work.

I thought to run this, but it didn't work...

echo "
rdr pass inet proto tcp from 127.0.0.1 to 10.20.154.24 port 1111 -> 127.0.0.1 port 8080
" | sudo pfctl -ef -

Solution

  • Found a solution. I had to make an alias out of the IP before setting the redirecting command

    sudo ifconfig lo0 10.20.154.24 alias