Skip to content

Instantly share code, notes, and snippets.

@marcelaraujo
Forked from gregjhogan/macos-port-forward.sh
Created November 30, 2020 10:22
Show Gist options
  • Save marcelaraujo/f0865d037d85f8a4357c92f6c2191a14 to your computer and use it in GitHub Desktop.
Save marcelaraujo/f0865d037d85f8a4357c92f6c2191a14 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