在Mac OS X上若想將443Port的Request轉到8443 Port,則可使用以下Command。
Forwaring Port 443 to 8443
echo "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
Show Rule:
sudo pfctl -s nat
如果沒有套用成功,可以透過 -s nat 又可以看到有設定值,請 disable/ enable 一次看看。
sudo pfctl -d #disables pfctl sudo pfctl -e #enables pfctl
Reference:
Mac pfctl Port Forwarding
https://salferrarello.com/mac-pfctl-port-forwarding/
How do I enable IP-forwarding in MacOS X?
https://stackoverflow.max-everyday.com/2017/08/how-do-i-enable-ip-forwarding-in-macos-x/