-4

I need the 'public' IP of my WiFi-Router, but this router is connected to an other router like this:

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.)

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
panteon00
  • 1
  • 2
  • You router IP should not change. Just hardcode it. – Franck Aug 26 '20 at 12:06
  • 2
    It seems you did not spend any time *researching* your problem, or trying to understand how to write a good question here. Thus I didnt spend more than 5 seconds to agree with the earlier suggestion that your question is nothing but a duplicate of an existing question. – GhostCat Aug 26 '20 at 12:06
  • This has been wrongly flagged as duplicate. Duplicate answer has nothing to do with the current problem he is having. I do not deny the question is badly formulated but it has been closed under wrong assumptions. – Franck Aug 26 '20 at 12:10
  • @Franck in this case, the IP is assigned throug DHCP, so it can change (sadly). – panteon00 Aug 26 '20 at 12:12
  • @GhostCat i've tried to research, but did not find anything. And sorry for the bad formulation, but i don't know, how to describe it better. (and as you probably already noticed, I am not a native speaker) – panteon00 Aug 26 '20 at 12:17
  • I think you could use an icmp ping to get routing info. You just need to count the hops and get the correct one. See http://coding.infoconex.com/post/2009/01/14/C-Traceroute-using-net-framework, https://stackoverflow.com/questions/1313743/tcp-traceroute-in-c-sharp and https://www.codeproject.com/articles/13174/icmp-the-ping-tracert - But mind that this is probably _s l o w_ , so you may want to cache the value until it obviously lost the lease and got assigned a different ip. – Fildor Aug 26 '20 at 12:18
  • @panteon00 Even through DHCP you can assign fix ip to that wifi router. You just set it's MAC address in the previous router in the chain and assign `10.0.0.2` to it and it will always be `10.0.0.2` – Franck Aug 26 '20 at 12:34
  • @Fildor thanks, i will try it :) – panteon00 Aug 26 '20 at 12:45
  • @Franck in this case not, it is not my router/dhcp-server ._. – panteon00 Aug 26 '20 at 12:46
  • A router has only one IP address. Depending on settings and mask will determine your routes. What are out trying to do? If you are trying to change settings in router take you laptop and directly connect to the router. – jdweng Aug 26 '20 at 13:10

1 Answers1

0

@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. 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. You will automatically get your desired 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.

Solution 2: You can connect a switch between your WiFi router and the service provider's router. Then connect both your WiFi router and the client PC on switch. And you will get the desired 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. Most of the times, if the Router is owned by your ISP then they won't allow you to use a switch.

nvt_dc
  • 133
  • 1
  • 9