OS X:从ipfw到pfctl-转发端口80和443


12

我找到了一种使用ipfw将端口80和443转发到其他任意端口(在我的情况下为3000和3001)的方法。但是不推荐使用ipfw,而将其替换为pfctl。这是我的ipfw声明:

sudo ipfw flush
sudo ipfw add 100 fwd 127.0.0.1,3000 tcp from any to me 443
sudo ipfw add 200 fwd 127.0.0.1,3001 tcp from any to me 80
sudo ipfw show

我如何用pfctl做同样的事情?


这是您在这里回答的重复问题: superuser.com/questions/473039/pfctl-port-forwarding-in-mac-osx
chris

Answers:



0

看到这个AskDifferent答案

要将所有端口80流量转发到端口8080,可以在“终端”命令行中输入以下内容。

echo "rdr pass inet proto tcp from any to any port 80 -> 127.0.0.1 port 8080" | sudo pfctl -ef -

取自https://salferrarello.com/mac-pfctl-port-forwarding/

要将端口80和443转发到端口3000和3001,请使用以下命令:

echo "rdr pass inet proto tcp from any to any port 80 -> 127.0.0.1 port 3000" | sudo pfctl -ef -
echo "rdr pass inet proto tcp from any to any port 443 -> 127.0.0.1 port 3001" | sudo pfctl -ef -
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.