有什么办法可以克服 TCP/IP 应用程序上的路由器端口转发吗?
我需要通过 TCP/IP 连接到计算机 我有外部 IP,但没有端口转发,我无法连接到服务器。
有没有办法配置服务器接受服务器定义的外部IP和端口上的连接,而无需配置路由器? (emule 是如何做到的?或其他点对点应用程序?)
I need to connect to computer over TCP/IP I have the external ip but without port forwarding I can't connect to the server.
Is there any way to configure the server to accepts connection on the external ip and port defined by the server without configuring the router ? (How does emule do it ? or other peer to peer application?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
你需要弄清楚情况。 目标计算机是否位于执行 NAT 的路由器后面?
如果是这样的话,答案是否定的。
服务器无法接受外部IP上的连接,因为外部IP是路由器的IP,并且服务器只能接受路由器转发给它的连接,因为没有到服务器的直接路径。
然而,有一些方法可以规避 NAT 引起的此类问题。 它们通常涉及 NAT 后面的计算机建立出站连接,然后用于通信。 请参见例如
http://en.wikipedia.org/wiki/Hole_punching
通用即插即用,正如其他答案中引用的那样,也可能允许这样做。
You need to clarify the situation. Is the target computer behind a router that does NAT?
If that is the case, the answer is no.
The server cannot accept connections on the external IP, because the external IP is the IP of the router, and the server can only accept connections that the router forwards to it, as there is no direct path to the server.
There are however some ways to circumvent problems like this caused by NAT. They usually involve the computer behind the NAT making an outbound connection, which is then used for communication. See e.g.
http://en.wikipedia.org/wiki/Hole_punching
Universal Plug and Play, as cited in the other answer, also may allow this.
理想情况下,您希望 NAT 客户端启动连接,但如果不可能,您需要查看 STUN 或 UPnP
STUN 是一个工具和协议的集合,允许您打孔通过NAT。 它可能需要未经过 NAT 处理的服务器的配合。
这可能会失败,具体取决于 NAT 实现。
UPnP 是面向 NAT 路由器的协议,它可以允许客户端动态转发所需的端口。 并非所有 NAT 路由器都支持此功能,但大多数现代路由器可能会支持。
Ideally you want to have the NATed client intiate the connection but if that's not possible you'll want to look into STUN or UPnP
STUN is a collection of tools and protocols which allows you to punch holes through NAT. It may require the cooperation of an un-NATed server.
This might fail depending on the NAT implementation
UPnP is a protocol towards the NAT router which can allow the client to dynamically forward the required ports. Not all NAT routers will support this, though most modern ones probably will.
我认为您需要研究通用即插即用:
http://en.wikipedia.org /wiki/Universal_Plug_and_Play
I think you need to look into Universal Plug and Play:
http://en.wikipedia.org/wiki/Universal_Plug_and_Play
基本上,您需要在这台计算机上安装一个程序来启动连接。 这就是 FogCreek CoPilot、LogMeIn 等程序如何允许远程管理 NAT 路由器后面的计算机,而无需配置路由器。
Basically you need a program on this computer which will initiate the connection. This is how programs like FogCreek CoPilot, LogMeIn, etc allow remote administration of machines behind NAT routers without configuring the router.