1

The http://whatsmyrouterip.com/ website can be used to resolve the public internet WAN IP address of a gateway router. However, it also shows the the private lan IP address of the gateway router and the private lan address of the device sending the request (e.g laptop).

How does the site get access to the private lan IP addresses given that the NAT source IP address of the page request is that of the gateway router? HTML headers?

E.G. Gateway router public IP address: 257.59.201.1. Gateway router private LAN address 192.168.1.1. Laptop private LAN address 192.168.1.25.

The site is HTTP so all this information is submitted in clear text.

  • There is no reason to think that the web server somehow probes or even knows your internal IP. Your laptop knows its own IP can can display it on a web page. – schroeder Mar 31 at 14:59
1

The site just tries some typical IP addresses for routers to see if something is there. Typically the router is either at the IP address xx.xx.xx.1 or xx.xx.xx.254 where the IP address is from the range of private IP addresses. It tries these and some other addresses in the range of the local network(s). Which local networks these are seem to be determined using WebRTC (thanks for schroeder@ to pointing this out - see his comment for more information).

This behavior can be traced if using the developer tools in the browser and looking at the requests taken:

enter image description here

If there is some kind of response when accessing HTTP on these IP addresses it is assumed that this is the admin interface of the router. It cannot actually read the content to check if this is a router but just checks based on the timeout of the request if it was successful or not. Thus, if there is some non-router at such IP it will guess wrong (as it does on my system) and if the routers admin interface is on some address outside the local network it will fail to find it this way. But it will work for the typical setups users have at home.

  • line 2328 uses RTC to get local IP – schroeder Mar 31 at 15:06
  • it's a copy of the code here: stackoverflow.com/a/32841043/1060378 – schroeder Mar 31 at 15:08
  • @schroeder: Thanks for the feedback, I've included it in the answer. Looks like I have too much local IP addresses on my system and that's why it tries lots of different networks (and also guesses my router IP wrong). – Steffen Ullrich Mar 31 at 15:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.