I recently came across this website called whatsmyrouterip.com. How does this website know both my private and public router IP address?
Asked
Active
Viewed 371 times
1 Answers
6
It looks like it tries to fetch the web page at each of a list of common router local IPs with JavaScript, deciding that it's found it when one responds. It uses jQuery's $.get()
, but there are lots of ways to fetch one a web page from within another1. This assumes that the router has a web administration panel on port 80, but they usually do.
The relevant code is on and around line 2495 of the source code for the page (view-source:http://whatsmyrouterip.com/):
2463 var ips = [["10.0.0.10", []], ["10.0.0.100", []], ["10.0.2.1", []], ...
<snip>
2495 $.get('http://' + currentIp[0], function () {
2496 foundIp();
2497 });
1Well, getting the content may be tricky because of Same-Origin Policy, but a request that fails because of SOP and one that fails because the site doesn't exist look different so you can still tell if there's something there or not.
Silver
- 316
- 1
- 4