简体   繁体   English

如何获取路由器的“公共”接口IP?

[英]How to get the 'public' interface IP of a router?

I need the 'public' IP of my WiFi-Router, but this router is connected to an other router like this:我需要我的 WiFi 路由器的“公共”IP,但此路由器已连接到其他路由器,如下所示:

Internet --- 1.2.3.4 |Router| 10.0.0.1 --- 10.0.0.2 |WiFi-Router| 192.168.0.1 --- 192.168.0.2 |Client|

In this example, I am the Client and want to get '10.0.0.2' (via C#, Java or similar. Concepts would be enough.)在这个例子中,我是客户端并且想要获得“10.0.0.2”(通过 C#、Java 或类似的。概念就足够了。)

@panteon00 Your answer seems to be quite simple, your WiFi router is getting the IP 10.0.0.2 just because you have connected the Ethernet cable from Router to WiFi router directly. @panteon00 您的答案似乎很简单,您的 WiFi 路由器正在获取 IP 10.0.0.2,因为您已将以太网电缆从路由器直接连接到 WiFi 路由器。 I can suggest two things which you can try in your case.我可以建议您可以在您的情况下尝试的两件事。

Solution 1: You can just plug off the Ethernet cable from WiFi router and then plug it on your client machine.解决方案 1:您可以从 WiFi 路由器上拔下以太网电缆,然后将其插入客户端计算机。 You will automatically get your desired IP.您将自动获得所需的 IP。

Note : If you do so, your other devices won't get Internet connection as you have plugged off the Ethernet cable from WiFi router.注意:如果您这样做,您的其他设备将无法连接到 Internet,因为您已从 WiFi 路由器上拔下以太网电缆。

Solution 2: You can connect a switch between your WiFi router and the service provider's router.解决方案 2:您可以在您的 WiFi 路由器和服务提供商的路由器之间连接一个交换机。 Then connect both your WiFi router and the client PC on switch.然后在交换机上连接您的 WiFi 路由器和客户端 PC。 And you will get the desired IP.您将获得所需的 IP。

Note: You must take permission from the owner of router before implementing solution 2 as you will be consuming multiple IPs from their IP stack.注意:在实施解决方案 2 之前,您必须获得路由器所有者的许可,因为您将使用其 IP 堆栈中的多个 IP。 Most of the times, if the Router is owned by your ISP then they won't allow you to use a switch.大多数时候,如果路由器归您的 ISP 所有,那么他们将不允许您使用交换机。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM