Solved

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

Posted on 2011-09-18
3
331 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 83

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

Turn Insights into Action

Communication across every corner of your business is essential to increase the velocity of your application delivery and support pipeline. Automate, standardize, and contextualize your communication processes with xMatters.

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

691 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