?
Solved

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

Posted on 2011-09-18
3
Medium Priority
?
342 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 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

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

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

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month16 days, 17 hours left to enroll

864 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