连接到 NAT 和防火墙后面的 FTP 服务器,无需端口转发
我有一个关于 NAT 穿越的新问题需要解决。 我正在部署一个 C# 应用程序,该应用程序在事件发生时启动 FTP 服务器。 问题是运行 FTP 服务器的计算机位于 NAT/防火墙路由器后面,因此我无法从任何连接到 Internet 的外部 PC 访问它。 所以我希望能够从我的 PC 连接到 FTP 服务器,但端口转发不是一个选项。
我读过几篇关于打孔、UPnP 等的文章,但我不能依赖 UPnP,因为我不知道路由器是否支持它。
我已经研究了 NAT 穿越的问题,目前解决此问题的唯一方法是从运行 FTP 服务器的计算机发起连接(换句话说,它应该充当客户端,以便 NAT IP/PORT 转换的规则)。但是,我认为没有任何 Windows FTP 服务器具有此功能。
由于我有一个没有 Natted 的远程 VPS 服务器,并且我可以在其中端口转发我想要的任何内容,因此我正在考虑通过 VPS 在客户端和服务器之间创建一条隧道。
FTP服务器(开始连接)--> VPS ---->客户端(连接)
FTP 服务器 <--- VPS <--- 客户端(回复)
但是我不知道是否有办法做到我所解释的,或者是否有一些更简单的方法可以做到这一点。任何帮助表示赞赏。
I've a new issue to solve about NAT traversal.
I'm deploying a C# application that starts a FTP server when an event occur.
The issue is that the machine running the FTP server is behind a NAT/Firewall router so i cannot reach it from any external PC connected to the Internet.
So i want to be able to connect from my PC to the FTP server but port-formwarding is not an option.
I've read several articles about Hole punching, UPnP and so on but i cannot rely on UPnP since i don't know if a router supports it.
I've studied the issue of NAT traversal and at this point, the only way to solve this issue is to initiate the connection from the machine which is running the FTP server (in other way it should act as a client so that the NAT has a rule for the IP/PORT translation). However, i don't think any Windows FTP server has this feature.
Since i've a Remote VPS Server not Natted and where i can port-forward anything i want, i was thinking to create a tunnel between client and server trough the VPS.
FTP Server (Start the connection to the) --> VPS ---> Client (Connection)
FTP Server <--- VPS <--- Client (reply)
However i don't know if there's a way to do what i explained or if there's some easyer way to do that. Any help is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
一个可能消除问题的解决方案是向服务器添加一条包含以下内容的规则:您的应用程序名称(或您使用的端口,我不推荐这样做)并允许操作。
仅供参考,这不是编程解决方案,而是一个网络解决方案。
one solution that could be erasing question is to add a rule to server containing this : your application name (or the port you use ,i don't recommend this) and allow action .
FYI this is not programming solution but it's a network solution.
我使用 Open.NAT 库。它打开端口 21,并将条目添加到兼容调制解调器/路由器上的 UPnP 表中。检查在线打开的端口确认连接。
恕我直言,可能是最好的解决方案。
I use Open.NAT library. It opens port 21, and adds entry to UPnP table on the compatible modem/router. Checking port open online confirms connectivity.
Probably the best solution imho.
如果您不开发供其他人使用的应用程序,您可以使用 Hamachi 之类的东西,它创建虚拟专用网络,因此它的行为就像计算机在 LAN 上一样,因此不需要端口转发。
If you're not developing application that will be used by other people, you can use something like Hamachi which creates virtual private network so it acts like computers are on LAN therefore making port forwarding not necesarry.
简单的解决方案是确保您的 FTP 服务器具有公共 IP 地址并侦听传入的 FTP 请求。
但是我不知道是否有一种方法可以做到我所解释的,或者是否有一些更简单的方法可以做到这一点。任何帮助表示赞赏。
您尝试使用此其他解决方案执行的操作称为使用代理。它也类似于类似 TURN 的解决方案。如果配置正确并且具有公共 IP 地址,一旦您的服务器与代理建立连接,代理肯定可以将流量转发到您的服务器。
The easy solution is to make sure your FTP server has a public IP address and listen to incoming FTP requests.
However I don't know if there's a way to do what I explained or if there's some easyer way to do that. Any help is appreciated.
What your are trying to do with this other solution is called using a proxy. It is also similar to a TURN like solution. If properly configured and if it has a public IP address, the proxy can surely forward traffic to your server once your server has established a connection with the proxy.