连接到私人IP [英] connecting to a private ip
本文介绍了连接到私人IP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想连接到位于路由器后面的系统.我知道路由器的公共地址以及系统的专用ip(始终固定).如何与专用ip建立套接字连接?
I want to connect to a system which is behind a router. I know the public address of the router as well as the private ip (fixed always) of the system. How do i establish socket connection with the private ip?
推荐答案
这就是为什么有人说他们在路由器后面时说他们在防火墙"后面的原因. Internet的邪恶病毒无法利用路由器后面的计算机上的任何软件(前提是路由器管理员未以有趣的方式配置它,例如,通过启用
This is why some people say that they are behind a "firewall", when they are behind a router. The Evil Viruses Of The Internet are not able to exploit any software on a computer behind a router (provided that the router admin didn't configure it in the funny way, for example by enabling DMZ).
您仍然有一些选择:
- 与路由器管理员对话,并让他为您转发端口
- 取出路由器,将目标"计算机放在路由器所在的位置,或启用DMZ(仅在路由器后面只有一台计算机的情况下才有意义). 警告:首先在目标计算机上安装防火墙!
- 将插座旋转180度.使路由器后面的计算机与具有公共IP地址的服务器建立连接
- 如果您的路由器支持,请使用 UPnP 之类的东西
- 为您的计算机获取一个专用的IP地址,并将路由器配置为将所有流量切换到该IP地址到您的计算机(这与DMZ类似,但是如果路由器后面有多台计算机,则可以使用). 警告:首先在目标计算机上安装防火墙!
- 使用NAT遍历. 此处上有一篇非常好的文章.简化版本是客户端与某个远程服务器建立连接.服务器可以在客户端的路由器上看到打开的端口号,并且该端口已分配给客户端的计算机,因此服务器(或共享此信息的其他计算机)可以建立与该端口的连接并到达客户端的应用程序. 警告:这不适用于所有路由器.有些路由器只是不允许这种情况发生.
- Talk to the router admin and make him forward a port for You
- Take the router out and put Your "target" computer where Your router was, or enable DMZ (this only makes sense if there was only one computer behind the router). Warrning: install a firewall on the target computer first!
- Turn the socket 180 degrees. Make the computer behind a router establish the connection to the server that has a public IP address
- Use something like UPnP, if Your router supports it
- Get a dedicated IP address for Your computer and configure router to switch all traffic to this IP address to Your computer (this is similar to DMZ, but would work if You have more than one computer behind the router). Warrning: install a firewall on the target computer first!
- Use NAT traversal. There is a very good article on the subject here. Simplified version is that client establishes connection to some remote server. The server can see the opened port number on the client's router and this port is assigned to the client's machine, so it (or some another computer sharing this information) may establish connection to that port and reach the client's application. Warrning: this doesn't work with all routers. Some routers just won't let this happen.
这篇关于连接到私人IP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文