我目前正在测试我的开发环境是否会在即将推出的新Mac OS 10.11上运行,如果我可以在其发布后立即升级。在我的测试机器上,我正在运行Beta Preview 3.一切似乎都运行良好。在Mac OS 10.11(El Capitan)上使用pfctl转发端口
我只能得到pfctl
转发我的端口。我使用Vagrant和Parallels Desktop为本地Web服务器运行Debian系统。 Vagrant将主机上的端口8080转发到guest虚拟机上的8080端口。所以127.0.0.1:8080
工作正常。但是在一些项目中,我希望具有与生产中相同的本地域。 (没有:8080)另外我更喜欢它。 ;-)
要做到这一点,我使用pfctl
在主机上转发80到8080。下面是我的配置文件:
〜/端口转发/ pf.conf中
rdr-anchor "forwarding"
load anchor "forwarding" from "/Users/nick/port-forwarding/rules.conf"
〜/端口转发/ rules.conf
rdr pass on lo0 inet proto tcp from any to any port 80 -> 127.0.0.1 port 8080
rdr pass on lo0 inet proto tcp from any to any port 443 -> 127.0.0.1 port 4433
要启用它,我运行:
sudo pfctl -vnf ~/port-forwarding/pf.conf
sudo pfctl -evf ~/port-forwarding/pf.conf
这给了我这个:
pfctl: Use of -f option, could result in flushing of rules
present in the main ruleset added by the system at startup.
See /etc/pf.conf for further details.
rdr-anchor "forwarding" all
Loading anchor forwarding from /Users/nick/port-forwarding/rules.conf
rdr pass on lo0 inet proto tcp from any to any port = 80 -> 127.0.0.1 port 8080
rdr pass on lo0 inet proto tcp from any to any port = 443 -> 127.0.0.1 port 4433
pfctl: Use of -f option, could result in flushing of rules
present in the main ruleset added by the system at startup.
See /etc/pf.conf for further details.
No ALTQ support in kernel
ALTQ related functions disabled
rdr-anchor "forwarding" all
Loading anchor forwarding from /Users/nick/port-forwarding/rules.conf
rdr pass on lo0 inet proto tcp from any to any port = 80 -> 127.0.0.1 port 8080
rdr pass on lo0 inet proto tcp from any to any port = 443 -> 127.0.0.1 port 4433
pf enabled
logout
Saving session...completed.
须藤pfctl的-s NAT说:
No ALTQ support in kernel
ALTQ related functions disabled
rdr-anchor "forwarding" all
到目前为止,它看起来不错,我想。但它不起作用。
127.0.0.1:80
- 无连接 127.0.0.1:8080
- 工程
我用约塞米蒂相同的文件,它工作正常那里。
有没有人知道是否有改变如何使用pfctl
或如果我做错了什么,或者如果有一个可以报告的错误。
非常感谢
尼克
有人问关于它的[超级] (http://superuser.com/questions/938999/osx-10-11-el-capitan-beta-pf-conf-behaviour-changed)和[此评论](http://superuser.com/questions/938999/osx-10-11-el-capitan-beta-pf-conf-behavior-changed#comment1281706_938999)尤其可以帮助您更改要转发的端口。 无论如何,你可能想要关注这个帖子,因为它不止在stackoverflow上。 –