Solved

Getting Internal/Router IP in PHP/Javascript/etc?

Posted on 2011-09-18
3
319 Views
Last Modified: 2012-05-12
I'm talking about those generic IPs that  router gives out, like 192.168.1.1 or 192.168.2.200 for example. From reading online alot of people state it is impossible, however, 'http://www.whatsmyip.org/more/' will give out the router IP, for example mine, on that website states 'Internal (LAN) IP: 192.168.1.68', which is correct.

I'm not certain how this can be replicated, I'm not looking for the real IP, I am looking the the internal/router IP. Any suggestions on how this can be achieved?

Right now using basic PHP/Javascript, can call any apache vars if needed too.
0
Comment
Question by:Valleriani
3 Comments
 
LVL 82

Accepted Solution

by:
Dave Baldwin earned 167 total points
ID: 36557824
It's a server variable, $_SERVER['REMOTE_ADDRESS'].   They are listed there.  This short PHP page will show all the $_SERVER variables that are available from your server.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>PHP Server Variables</title>
</head>
<body><h1>PHP Server Variables</h1>
<?php

//reset($_SERVER);
foreach($_SERVER as $key => $value) {
    echo "<b>$key :</b> $value<br />\n";
}
echo "<hr>";
echo "<b>ENVironment variables.</b><br>";
foreach($_ENV as $key => $value) {
    echo "<b>$key :</b> $value<br />\n";
}

?>
</body>
</html>

Open in new window

0
 
LVL 14

Assisted Solution

by:Scott Madeira
Scott Madeira earned 167 total points
ID: 36557849
For the internal address you can use the script from this site:

http://www.reglos.de/myaddress/MyAddress.html

It has a MyAddress.class Java program will get the local IP address (192.168.1.x, for example.)

Here is a link to a demo page that gets the address of your computer.  http://www.reglos.de/myaddress/demo3.html


This is what the whatsmyip.org site uses.

Hope that helps.
0
 
LVL 7

Assisted Solution

by:boon86
boon86 earned 166 total points
ID: 36557865
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now