如何在OSX中将请求转发到本地网络中的docker机器

时间:2016-04-06 13:58:02

标签: macos docker nat portforwarding

我目前正在本地网络中运行一台码头机,其IP&端口是192.168.99.100:8080 马上。我想从本地网络的某个地方连接这台机器并访问它,所以我找到的最好的方法是将我的笔记本电脑发送的请求NAT转接到docker机器。 换句话说,已经发送到我的笔记本电脑的每个请求都将通过自己的IP和端口发送到docker机器! 我使用pfctl来做这个但是当我检查端口8585以找出哪个服务正在监听这个端口时,我找不到任何东西,听起来好像请求没有到达(到达)目的地!

我做了如下:

1- csrutil disable

2-我的角色: /etc/pf.anchors/mazafard:

rdr pass on en0 inet proto tcp from any to 192.168.20.203 port 8585 -> 192.168.99.100 port 8080

3-我的pf conf /etc/pf-mazafard.conf

rdr-anchor "forwarding"
load anchor "forwarding" from "/etc/pf.anchors/mazafard"

sudo pfctl -vnf /etc/pf.anchors/mazafard


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 pass on en0 inet proto tcp from any to 192.168.20.203 port = 8585 -> 192.168.99.100 port 8080

sudo pfctl -evf /etc/pf.anchors/mazafard


fctl: 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 pass on en0 inet proto tcp from any to 192.168.20.203 port = 8585 -> 192.168.99.100 port 8080
pfctl: pf already enabled

telnet 192.168.20.203 8585

Trying 192.168.20.203...
telnet: connect to address 192.168.20.203: Operation timed out
telnet: Unable to connect to remote host

我的OSX v:10.11.4

Docker版本1.9.1,构建a34a1d5

Boot2Docker版本1.11.0-rc3,build

0 个答案:

没有答案