Skip to content

Instantly share code, notes, and snippets.

@gregjhogan
Last active October 12, 2022 07:19
Show Gist options
  • Save gregjhogan/ba118222c66c81209c41be24c28ceebf to your computer and use it in GitHub Desktop.
Save gregjhogan/ba118222c66c81209c41be24c28ceebf to your computer and use it in GitHub Desktop.
local port forwarding on macOS
#!/bin/bash
ifconfig lo0 alias 127.0.1.1
ifconfig lo0 alias 127.0.10.1
# clear rules
pfctl -F all -f /etc/pf.conf
# set rules
echo "
rdr pass inet proto tcp from any to 127.0.1.1 port 443 -> 127.0.1.1 port 1443
rdr pass inet proto tcp from any to 127.0.10.1 port 443 -> 127.0.10.1 port 10443
" | sudo pfctl -ef -
# list rules
# pfctl -s nat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment