Is there a way to get the visitors *local* IP-address in javascript? I mean his LAN address like 192.168.1.x, not his regular IP-address.
I found several approaches that attempt to do this, but they either give me the external (regular) IP address, or they give 127.0.0.1 which doesn't really tell me anything. I need the local network address.
Just an alert saying "your machine's local network IP is 10.0.0.139" would be great.
To get the private network address (10.x.x.x, 192.168.x.x, etc) the user will need to be able to hit a web server inside the private network without being routed outside. In short, if you're trying to grab someones private network address from outside that network you can't.
Thanks for the reply. I'm not neccessarily grabbing the internal address from outside, I only need Javascript (which is obviously local/inside) to determine it.
Once I have the address in JS, I can of course fill it in some form input field or do a XmlHttpRequest or whatever to process it further.
Is there some way for javascript to detect the local IP address? I've seen some attempts with socket connections or similar approaches, but all in vain
Is there a way to get the visitors *local* IP-address in javascript? I mean his LAN address like 192.168.1.x, not his regular IP-address.
I found several approaches that attempt to do this, but they either give me the external (regular) IP address, or they give 127.0.0.1 which doesn't really tell me anything. I need the local network address.
Just an alert saying "your machine's local network IP is 10.0.0.139" would be great.
with a little help from java:
Code:
function myIP(){ var vi="uses java to get the users local ip number"
var yip2=java.net.InetAddress.getLocalHost();
var yip=yip2.getHostAddress();
return yip;
}//end myIP
alert("your machine's local network IP is "+ myIP())
//shows: your machine's local network IP is 192.17.145.155
Hey, thanks, look promising, however this doesn't seem to work on my PC? (I do have the latest Sun Java installed)
Just to be sure, I'd have to include that as regular javascript, right? This is the exact html file I tried:
Code:
<html><head><script type='text/javascript'>
var yip2=java.net.InetAddress.getLocalHost();
var yip=yip2.getHostAddress();
alert("your machine's local network IP is "+yip);
</script></head><body>test</body></html>
You cannot get local (internal) ip address. Networks are almost ALWAYS configured to hide internal ip, and thus you can only get the external (the one set by ISP) ip. Don't know the code to do this though.
If your windows user, open command prompt and type ipconfig
This will NOT change anything because you haven't told it to. It simply shows your current ip configuration. Write down the ip address. Now go to google and search 'what is my ip'. This gives you your external ip
We all have baggage to carry in life, unfortunately for me I always get the trolley with the wonky wheel...
Code:
Youre = {
STILL_not_getting_it:function(){
alert("YOU, the original poster / thread starter NEED to POST the code and NOT a LINK.");
},
MissingThePoint:function(msg){
alert("You're missing the point. " + msg);
}
}
Youre.STILL_not_getting_it();
Is there a way to get the visitors *local* IP-address in javascript? I mean his LAN address like 192.168.1.x, not his regular IP-address.
When you go to this website, you will see your own IP address. Right below that IP address you see:
LAN: Get my LAN address [button/link]
Click on "Get my LAN address" and you will see an IP like 192.168.0.x or something similar. Now you have something to show when you explain your question to other people.
Originally Posted by Azzdog dev
You cannot get local (internal) ip address. Networks are almost ALWAYS configured to hide internal ip, and thus you can only get the external (the one set by ISP) ip.
Then how come this website did manage to show my internal IP address? JavaScript works locally / internal and internal IP address are not hidden to internal applications.
It's possible with this script witch load dynamicaly a javascript build with php.
Code:
<?php
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Content-Type:text/javascript;charset=utf-8");
if (!empty($_GET)) {
// lecture du GET et execution des tāches
}
exit("alert('Votre adresseIP est : ".$_SERVER['REMOTE_ADDR']."');");
?>
I have include a iptocountry php file which give now the country... Thank you for indicating me of possible errors.
Which is flawed because this method of IP address to geo location is not 100% accurate.
When I was a BT Internet customer, the ISP for BT Internet was Yahoo who uses servers in the USA and therefore all the UK Yahoo ISP users have an IP address block in the USA when they are in the UK. That is just one ISP and one customer amongst millions.
Addressing of blocks is not sequential, a country will not have a single contiguous block, it will have 100's to 1000's of blocks that are allocated in small sequences.
A proxy server breaks any ip to geo location detection.
I will give you an idea of how far off geo location by this method is, Yahoo and other sites seem to think I live in Maidenhead, Kent. Nope, sorry, never lived in Kent, I have an Aunt that lives near to Maidenhead that I haven't seen in 36 years, but I don't live in Maidenhead, I live about 2 hours drive north in the East Midlands.
Word to the wise, do not rely on this method of fixing your users location.
We all have baggage to carry in life, unfortunately for me I always get the trolley with the wonky wheel...
Code:
Youre = {
STILL_not_getting_it:function(){
alert("YOU, the original poster / thread starter NEED to POST the code and NOT a LINK.");
},
MissingThePoint:function(msg){
alert("You're missing the point. " + msg);
}
}
Youre.STILL_not_getting_it();
Thank you for this information Junk Male, even if everybody has no aunt to Maidenhead, we shall retain that the geolocalisation is uncertain. It's like the bikini. It gives ideas even if it can hide the main part...
Bookmarks