?
Solved

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

Posted on 2011-09-18
3
Medium Priority
?
336 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 668 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 668 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 664 total points
ID: 36557865
0

Featured Post

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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…
Suggested Courses

765 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