如何使TCP服务器在路由器(NAT)后面工作而无需任何重定向配置 [英] How do I make a TCP server work behind a router (NAT) without any redirection configuration needed

查看:172
本文介绍了如何使TCP服务器在路由器(NAT)后面工作而无需任何重定向配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

情况如下.我有两台机器A和B: 答:客户端(在NAT之后) B:服务器(位于NAT之后)

The scenario is the following. I have two machines A and B: A: Client (behind NAT) B: Server (behind NAT)

我希望B能够在任何给定的端口上侦听,以便A可以通过该特定的TCP端口将数据包发送到B并接收任何响应.如果两台计算机都不在NAT后面,那将是一个非常直接的过程.但是,我如何使它工作,以便即使B在路由器后面也能工作,而不必他去改变路由器配置,从而启用某些端口转发等功能.

I want B to be able to listen on any given port, so that A can send packets to B through that specific TCP port and receive any response. If both machines are not behind a NAT it is pretty straight foward process. However how do I make it work so that it works even when B is behind a router, without him having to go change the router configuration enable some port forwarding etc...

例如,在没有用户需要配置的情况下,torrent客户端等对等程序如何工作?

For example, how do peer-to-peer programs like torrent clients work without the user having anything to configure?

推荐答案

代理服务器的替代方法是配对服务器.匹配器不会协商所有流量,而只是进行协商直到对等端可以相互通信为止.这涉及查找对等方的外部公共IP,并与每个IP进行对话,以便防火墙/路由器知道对等方希望进行通信.

An alternative to a proxy server is a match-making server. Instead of proxying all of the traffic, the match maker just negotiates until the peers can talk to each other. This involves finding the external public IPs of the peers and talking to each one so that the firewall/router knows that the peers wish to communicate.

这称为打孔,通常必须由媒人来完成比同龄人自己.但是,一旦打洞,媒人就可以告诉同龄人彼此,他们可以直接进行交流.

This is called hole punching and it often has to be done by the match maker rather than the peers themselves. Once the hole are punched though, the match maker can tell the peers about each other and they can communicate directly.

这篇关于如何使TCP服务器在路由器(NAT)后面工作而无需任何重定向配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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