我需要将所有发往 127.0.0.1:5432 的流量转发到 macOS Big Sur 上的 192.168.1.103:543。Windows 上的类似命令是
netsh interface portproxy add v4tov4 listenaddress=127.0.0.1 listenport=5432 connectaddress=192.168.1.103 connectport=5433
谢谢。
答案1
您可以使用 rdr 命令将流量从 127.0.0.1:5432 转发到 192.168.1.103:543
echo "
rdr pass on lo0 inet proto tcp from any to self port 5432 -> 192.168.1.103 port 543
rdr pass on en0 inet proto tcp from any to any port 5432 -> 192.168.1.103 port 543
rdr pass on en1 inet proto tcp from any to any port 5432 -> 192.168.1.103 port 543
" | sudo pfctl -ef -