有没有办法克服tcp / ip应用程序上的路由器端口转发

时间:2021-09-06 22:16:39

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 define by the server without configuring the router ? (how does emule does it ? or other peer to peer application )

我需要通过tcp / ip连接到计算机我有外部IP但没有端口转发我无法连接到服务器。有没有办法配置服务器接受服务器定义的外部IP和端口上的连接而不配置路由器? (emule如何做到这一点?或其他对等应用程序)

4 个解决方案

#1


You need to clarify the situation. Is the target computer behind a router that does NAT?

你需要弄清楚情况。目标计算机是否在做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.

服务器无法接受外部IP上的连接,因为外部IP是路由器的IP,并且服务器只能接受路由器转发到它的连接,因为没有到服务器的直接路径。

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.

然而,有一些方法可以避免由NAT引起的这类问题。它们通常涉及NAT后面的计算机进行出站连接,然后用于通信。参见例如

http://en.wikipedia.org/wiki/Hole_punching

Universal Plug and Play, as cited in the other answer, also may allow this.

如其他答案所述,通用即插即用也可能允许这样做。

#2


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

理想情况下,您希望让NATed客户端启动连接,但如果不可能,您将需要查看STUN或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

STUN是一系列工具和协议,允许您通过NAT打孔。它可能需要非NAT服务器的合作。这可能会失败,具体取决于NAT实现

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.

UPnP是NAT路由器的协议,它允许客户端动态转发所需的端口。并非所有的NAT路由器都会支持这种情

#3


I think you need to look into Universal Plug and Play:

我认为你需要研究通用即插即用:

http://en.wikipedia.org/wiki/Universal_Plug_and_Play

#4


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.

基本上你需要在这台计算机上启动一个程序来启动连接。这就是FogCreek CoPilot,LogMeIn等程序允许远程管理NAT路由器后面的机器而无需配置路由器。

#1


You need to clarify the situation. Is the target computer behind a router that does NAT?

你需要弄清楚情况。目标计算机是否在做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.

服务器无法接受外部IP上的连接,因为外部IP是路由器的IP,并且服务器只能接受路由器转发到它的连接,因为没有到服务器的直接路径。

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.

然而,有一些方法可以避免由NAT引起的这类问题。它们通常涉及NAT后面的计算机进行出站连接,然后用于通信。参见例如

http://en.wikipedia.org/wiki/Hole_punching

Universal Plug and Play, as cited in the other answer, also may allow this.

如其他答案所述,通用即插即用也可能允许这样做。

#2


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

理想情况下,您希望让NATed客户端启动连接,但如果不可能,您将需要查看STUN或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

STUN是一系列工具和协议,允许您通过NAT打孔。它可能需要非NAT服务器的合作。这可能会失败,具体取决于NAT实现

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.

UPnP是NAT路由器的协议,它允许客户端动态转发所需的端口。并非所有的NAT路由器都会支持这种情

#3


I think you need to look into Universal Plug and Play:

我认为你需要研究通用即插即用:

http://en.wikipedia.org/wiki/Universal_Plug_and_Play

#4


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.

基本上你需要在这台计算机上启动一个程序来启动连接。这就是FogCreek CoPilot,LogMeIn等程序允许远程管理NAT路由器后面的机器而无需配置路由器。