从内部网络使用其公用IP到达内部计算机 [英] Reach internal machine using its public IP from internal network

查看:75
本文介绍了从内部网络使用其公用IP到达内部计算机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在VMWare vCloud中工作。

Working in VMWare vCloud.

Web服务器的内部IP为172.16.0.61,公共IP为148.25.6.22(发明数);
App Server具有内部ip 172.16.0.52

Webserver has internal ip 172.16.0.61, public ip 148.25.6.22 (invented numbers); App Server has internal ip 172.16.0.52

从App Server中,我可以使用其内部172.16.0.61 ping和冲浪Webserver,但是...如何(通过App Server)使用其公共148.25.6.22到达它?

From App Server I can ping and surf Webserver using its internal 172.16.0.61, but... how can I reach it (from App Server) using its public 148.25.6.22?

只是在寻找让我对App Server说
148.25.6.22 => 172.16.0.61

Just searching for something that let me say to the App Server 148.25.6.22 => 172.16.0.61

如果我拥有域名,则可以在/ etc / hosts中对其进行解析,但是目前我只有ip。
预先感谢

If I had a domain name I could resolv it in /etc/hosts, but at the moment I have just ip. Thanks in advance

推荐答案

如果我正确理解您的服务器,则您的服务器位于NAT后面,该NAT伪装了它们的IP地址(这就是为什么您的Web服务器既有内部IP地址又有外部IP地址的原因-外部IP地址实际上是NAT的公共地址。)

If I understand you correctly, your servers are behind a NAT, which masquerades their IP addresses (which is why your webserver has both an internal and an external IP address - the external one is actually the NAT's public address).

您可以在自己的服务器上定义本地路由appserver,它将发送到148.25.6.22的数据包定向到172.16.0.61,但这没有达到目的,因为这将导致appserver只将所有内容发送到内部地址。

You can define a local route on your appserver, which will direct packets sent to 148.25.6.22 to 172.16.0.61, however that defeats the purpose, as that would cause the appserver to just send everything to the internal address.

您应该做的是在NAT上配置端口转发-这意味着NAT将侦听您指定的端口,并且到达此端口的所有通信都将转发到Web服务器的内部IP到您指定的另一个端口,例如: 148.25.6.22:8080 => 172.16.0.61:8080 。现在,如果您的应用服务器连接到148.25.6.22:8080,则数据包将通过端口8080到达网络服务器。

What you should do is configure port forwarding on your NAT - this means that the NAT will listen on a port you specify, and all communication which reaches this port will be forwarded to the webserver's internal IP to another port you specify, for example: 148.25.6.22:8080 => 172.16.0.61:8080. Now, if your appserver connects to 148.25.6.22:8080, the packets will reach the webserver at port 8080.

这篇关于从内部网络使用其公用IP到达内部计算机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆