Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
314 views
in Technique[技术] by (71.8m points)

Mac如何通过pfctl或其他方式进行ip映射

公司内网需要windows软件认证才能访问,于是在mac中安装虚拟机通过nat模式将内网的几个ip映射到虚拟机的相应端口上,然后mac就可以通过直接访问虚拟机ip的特定端口来访问相应内网服务器。
如内网服务器192.192.2.101:1070,虚拟机ip:10.211.55.3,通过在虚拟机中执行如下命令进行端口转发:

netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=1070 connectaddress=192.192.2.101 connectport=1070

至此可以实现在mac中访问10.211.55.3:1070(虚拟机IP+映射的端口)来访问内网服务器,但我想的是不用改配置文件,直接让mac在访问192.192.2.101:1070内网地址时将请求转发到10.211.55.3:1070中去,了解到pfctl命令,但一直没有尝试成功:

echo "rdr pass on lo0 inet proto tcp from any to 192.192.2.115 port 1521 -> 127.0.0.1 port 1521" | sudo pfctl -ef -

如何实现mac访问ipA的时候实际上访问的是ipB呢,请大神帮忙?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...