로컬호스트 8000 => 로컬호스트 3000 으로 하는법과 삭제법은 다음과 같다.
#!/usr/bin/env bash
# forward localhost:8000 to localhost:3000
echo "rdr pass on lo0 inet proto tcp from any to 127.0.0.1 port 8000 -> 127.0.0.1 port 3000" | sudo pfctl -ef -
# remove it
sudo pfctl -F all -f /etc/pf.conf
참고) https://gist.github.com/sbolel/db5ad50c3f72c6a18ab6c7e7a924dcb9
외부에서 오는 모든 [80 포트 트래픽을 로컬호스트 8080] 으로, [443 포트 트래픽을 로컬호스트 8443] 으로 돌리는 법은 다음과 같다.
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 -
현 포트포워딩 규칙 보는법
sudo pfctl -s nat
참고) https://salferrarello.com/mac-pfctl-port-forwarding/
Mac pfctl Port Forwarding - Sal Ferrarello
Historically, I used ipfw from the command line to do port forwarding on my Mac. Unfortunately, as of Yosemite OS X 10.10 ipfw has been removed. (In all fairness, ipfw has been deprecated for some time but I continued using it because it was way easier tha
salferrarello.com
'시행착오 > [Mac]' 카테고리의 다른 글
맥북 초기세팅 꿀팁 (0) | 2022.05.19 |
---|---|
맥북 화면 녹화, 소리 동시 기록 방법 (0) | 2021.05.11 |
m1 맥에서 homebrew 설치법 (0) | 2021.02.14 |