我目前正在测试我的开发环境是否会在即将推出的MacOS10.11上运行,以及是否可以在发布后立即升级。在我的测试机器上,我现在运行的是Beta 3,一切看起来都很好。
我只能让pfctl转发我的端口。我使用为本地web服务器运行Debian系统。流浪汉将主机上的8080端口转发到客人上80个端口。所以127.0.0.1:8080工作得很好。但在一些项目中,我想拥有与生产完全相同的本地领域。(没有8080)我也更喜欢它。;-)
为此,我使用pfctl在主机上转发80到8080。以下是我的配置文件:
~/端口-转发/pf.conf
rdr-anchor "forwarding"
load 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 为了启用它,我运行:
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.-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 -工作
我在Yosemite上使用了同样的文件,它在那里工作得很好。
是否有人知道如何使用pfctl发生了变化,或者我是否做错了什么,或者是否存在可以报告的bug。
非常感谢
尼克
发布于 2015-07-22 18:00:31
只适用于OSX10.11- El Capitan - Public Beta 1
在最新的10.11测试版中,127.0.0.1被阻塞。解决方案是什么?使用127.0.0.2。为此,请执行以下操作:
首先向环回别名sudo ifconfig lo0 alias 127.0.0.2 up添加127.0.0.2
修改pf规则以使用新别名。rdr pass proto tcp from any to any port 80 -> 127.0.0.2 port 8080
在不使用文件的情况下,从命令行:
echo "rdr pass proto tcp from any to any port {80,8080} -> 127.0.0.2 port 8080" | pfctl -Ef - <
https://stackoverflow.com/questions/31517368
复制相似问题