Skip to content

Instantly share code, notes, and snippets.

@dhlavaty
Created April 13, 2021 13:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhlavaty/c7700d640da73b53b84df32cb1e135fd to your computer and use it in GitHub Desktop.
Save dhlavaty/c7700d640da73b53b84df32cb1e135fd to your computer and use it in GitHub Desktop.
Mac pfctl Port Forwarding

Mac pfctl Port Forwarding

Forward Port 80 and 443 with Mac pfctl Port Forwarding

echo "
rdr pass inet proto tcp from any to any port 80 -> 127.0.0.1 port 8080
rdr pass inet proto tcp from any to any port 443 -> 127.0.0.1 port 8443
" | sudo pfctl -ef -

Remove Port Forwarding

sudo pfctl -F all -f /etc/pf.conf

Display Your Current Port Forwarding Rules

sudo pfctl -s nat

-original source https://salferrarello.com/mac-pfctl-port-forwarding/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment