且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从互联网访问本地网络内的服务器

更新时间:2022-06-22 22:47:51

如果路由器支持 uPnP,并且服务器应用程序请求它,路由器可以代表服务器应用程序打开端口.

If the router supports uPnP, and the server application requests it, the router can open the port on behalf of the server app.

这实际上只适用于消费级路由器,因为任何理智的管理员都会在真实网络上将其关闭.

This really only works on consumer grade routers since any sane admin will have turned this off on a real network.

编辑

在 C# 这里此处.

另一种方法是在 Internet 上众所周知的位置安装服务器.防火墙后面的应用程序创建到 Internet 服务器的持久连接.然后,用户连接到 Internet 服务器,该服务器将数据包中继到受防火墙保护的应用程序.teamviewer 等程序使用这种方法绕过 NAT.

The alternative is to have a server at a well known location on the internet. The application behind the firewall creates a persistent connection to the internet server. The user then connects to the internet server which relays packets to the firewalled application. Programs like teamviewer use this method to get around the NAT.