如何连接防火墙后面的两个客户端?

发布于 2024-08-01 21:13:54 字数 263 浏览 6 评论 0原文

当使用 Live Messenger 等即时消息应用程序或 Google Talk 桌面客户端时,计算机可以在彼此之间传输文件。 我不能肯定地说,但我相当确定计算机之间传输的数据不会通过微软或谷歌的 IM 服务器,而是装有 IM 软件的两台计算机直接相互通信。 我想知道客户之间是否或如何建立这种直接连接,以及我自己如何实现类似的东西。

我有一些使用个人网络的经验,但我只了解客户端-服务器关系,其中服务器始终在侦听(并且端口不被防火墙阻止),并且客户端在需要数据时向服务器发出请求。

When using an instant messaging application like Live Messenger or the desktop client for Google Talk, computers can transfer files between one another. I can't say for sure, but I'm fairly certain that the data being transferred between computers does not go through Microsoft's or Google's IM servers, rather the two computers with the IM software communicate directly with each other. I'm wondering if or how this direct connection between the clients is established and how I would implement something similar myself.

I have some experience working with personal networks but I only understand a client-server relationship, where the server is always listening (and ports are not blocked by a firewall) and the client makes a request to the server whenever data is needed.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

离笑几人歌 2024-08-08 21:13:54

如果两个客户端都位于未打孔的防火墙后面且未使用 VPN 软件,则它们将通过第 3 方服务器进行通信。 时期。

If both clients are behind a firewall that hasn't been pinholed and no VPN software is being employed they are communicating through a 3rd party server. Period.

執念 2024-08-08 21:13:54

如果我要实现这个,我会考虑几个选项。

  1. 让防火墙将给定端口转发到网络内的 PC。 这将允许您从外部世界连接到服务器。

  2. 让防火墙后面的客户端连接到防火墙外部的可见服务器。

简而言之,对话中的至少一方需要对其他方可见(服务器),以便他们可以连接到它。 不管怎样,一旦建立连接,客户端和服务器将能够毫无问题地来回通信。

If I were implementing this, I'd look at a couple of options.

  1. Have the firewall forward a given port to a PC inside the network. This will let you connect to a server from the outside world.

  2. Have the client(s) behind the firewall connect to a visible server outside of the firewall.

In short, at least one party in the conversation needs to be visible (the server) to the other(s) so they can connect to it. Regardless of how, once a connection is made, the client and server will be able to communicate back and forth without any problems.

っ〆星空下的拥抱 2024-08-08 21:13:54

执行大多数木马的操作:

反向连接

编辑:

如果两台机器位于防火墙后面,您将需要某种第三个“代理”

Do what most trojans do:

Reverse Connection

EDIT:

with two machines behind firewalls, you would need some kind of third 'Proxy'

梦过后 2024-08-08 21:13:54

我使用了一个名为 Hamachi 的程序,它有点像点对点-peer vpn(虚拟网络到网络)。 然后我按原样编写了客户端服务器应用程序。 这是一种获得互联网连接功能的快速方法,无需处理 NAT 路由器所需的技巧。

如果您需要“正确”地执行此操作,常用方法之一是udp 打洞。 当您发送网络请求时,您的防火墙知道需要返回数据作为响应。 诀窍是客户端 A 和客户端 B 都与 Internet 上的服务器联系。 服务器将客户端 A 发出的请求的详细信息传递给客户端 B,反之亦然。 一旦建立初始连接,即使主服务器不再存在,它们也可以继续通信。

I've used a program called Hamachi which is a bit like a peer-to-peer vpn (virtual network-to-network). Then I wrote the client server applications as is. It was a quick way to get the functionality of connecting over the Internet without the trickery needed for dealing with NAT routers.

If you need to do it 'properly', one of the common methods is udp hole punching. When you send a web request your firewall knows to expect back data in response. The trick is that both client A and client B contact a server on the Internet. The server passes details of the request client A made to client B and and vice versa. Once the initial connection is established they can continue communicate even if the main server is no longer there.

笑咖 2024-08-08 21:13:54

许多客户端使用一种称为“pin Holing”的方法:

我向您发送一个 UDP 数据包,这会在我的防火墙上戳一个洞(允许 UDP 数据包(假设是我的防火墙的响应)由您发送并由我)。 该数据包被防火墙丢弃。

你向我发送了一个 UDP 数据包,在你的防火墙上戳了一个洞。 该数据包应该会到达我,此时我可以发送另一个数据包来到达您,我们可以通过防火墙通过 UDP 进行通信。

There is a method used by many clients called "pin holing":

I send a UDP packet at you, which pokes a hole in my firewall (allowing UDP packets, assumed to be responses by my firewall, to be sent by you and received by me). That packet gets discarded by your firewall.

You send a UDP packet to me, poking a hole in your firewall. That packet should reach me, at which point I can send another one to reach you and we can communicate, through our firewalls, over UDP.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文