Unix系统命令学习 - pfctl

 

pfctl -- control the packet filter (PF) and network address translation (NAT) device

控制包过滤(PF)与NAT设备。

Synopsis 【简介】

【介绍】

DESCRIPTION

     The pfctl utility communicates with the packet filter device.  It allows ruleset and parameter configuration and retrieval of status information from the packet filter.

pfctl命令与包过滤设备通信。它可以实现规则集与参数设置以及从包过滤器获取状态信息。包过滤根据定义在pf.conf文件中的过滤规则来控制通过网络接口进入或者离开当前主机的数据包的种类。它还可以替换包的地址与端口。替换发出的数据包的源地址与端口被称为NAT(Network Address Translation), 这被用于链接内网到外网使的到外网的所有链接看起来都是来自同一个网关。替换进入内网的数据包目的地址与端口是用于将转接到不同的主机与端口。 也支持双向NAT。过滤规则在pf.conf描述。

 该数据包过滤器并不自己在接口设备间转发数据包。 开启数据包转发可以设置 sysctl 变量 net.inet.ip.forwarding 或者 net.inet6.ip6.forwarding 为 1.  修改sysctl.conf配置文件可以持久化该设置。

开启pf服务
sudo pfctl -ef /etc/pf.conf  或则 sudo pfctl -E

使用例子:

1, OSX实现端口转发( 80 -> 8080 ) 

https://www.jianshu.com/p/eefe3877650f

 

你可能感兴趣的:(运维,unix)