命令
# 查看配置文件
sudo vi /etc/pf.conf
# 关闭
sudo pfctl -d
# 开启+刷新规则
sudo pfctl -evf /etc/pf.conf
# 只刷新 更新规则
sudo pfctl -s rules
# 如何在命令行中刷新 PF 规则/NAT/路由表
pfctl -F all
# 如何在命令行中仅刷新 PF 规则
pfctl -F rules
配置文件
举例一:屏蔽某几个端口的tcp
NoRoutePorts = "{8081,8082, 8042, 8088, 50070}"
ExtIF = "{en0, en5}"
block in quick on $ExtIF proto tcp from any to any port $NoRoutePorts
参考:
https://zhuanlan.zhihu.com/p/44655145
https://man.linuxde.net/pfctl
https://blog.csdn.net/shuishen49/article/details/77587527
https://www.gwduan.com/web/computer/work-env/common/pf.html
https://www.zhihu.com/question/58516863/answer/1321535087
https://man.openbsd.org/pf.conf