Getting local IP address in javascript?
Moderator: General Moderators
Getting local IP address in javascript?
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.
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.
Re: Getting local IP address in javascript?
It seems unlikely that the browser would leak information about a network interface other than the one it is using to connect to the server. That would be like allowing the server to see the file structure of the client.
Re: Getting local IP address in javascript?
Well, strictly speaking, it's not 'leaking' anything to the server: I only need the IP address in Javascript, which is obviously local / client-side.
Re: Getting local IP address in javascript?
Any data JavaScript has access to can be sent back to the server.
Re: Getting local IP address in javascript?
Well, this page seems to do something similar with Java instead of JavaScript: http://www.auditmypc.com/anonymous-surfing.asp
Is this a security breach? And if it's possible with Java, isn't it with Javascript? (I mean because they both run locally, I know the two haven't got much else in common besides their name)
Is this a security breach? And if it's possible with Java, isn't it with Javascript? (I mean because they both run locally, I know the two haven't got much else in common besides their name)
Re: Getting local IP address in javascript?
I don't see any Java on that page. All of that information either comes from headers that the browser sent when requesting the page or is based on data that can be found in the $_SERVER array in PHP.
- Browser (user agent) comes from $_SERVER['HTTP_USER_AGENT'].
- IP address comes from $_SERVER['REMOTE_ADDR'].
- Hostname comes from doing an nslookup on the IP address.
- Location information comes from using geolocation based on the IP address, which I have no experience with.
Re: Getting local IP address in javascript?
I actually DO see my internal network IP on that page, but only after a popup from my firewall about java.exe
Someone else suggested to call a static java package from within javascript, like this:
However this didn't work on my PC (even though I have the latest Sun Java installed).
Someone else suggested to call a static java package from within javascript, like this:
Code: Select all
var yip2=java.net.InetAddress.getLocalHost();
var yip=yip2.getHostAddress();
alert("your machine's local network IP is "+yip);Re: Getting local IP address in javascript?
Unfortunately this gives the user's external IP and hostname only, which is trivial.rajiv wrote: This will get the user's Ip address and hostname....
I need their internal, local network IP, like "10.x.x.x" or "192.168.x.x".
Re: Getting local IP address in javascript?
Not every browser allow for direct javascript -> java access. You may need to create an applet exposing the functionality you need.Bram wrote:However this didn't work on my PC (even though I have the latest Sun Java installed).
Re: Getting local IP address in javascript?
Hi all,
does anybody experienced to use geolocation in Mainland China?
I wonder whether there is a javascript script that can tell the user latitude and longitude which work when being used in mainland china. My plan is after I got the value of latitude and longitude I will feed them into Baidu API and get the location from there.
Many thanks.
does anybody experienced to use geolocation in Mainland China?
I wonder whether there is a javascript script that can tell the user latitude and longitude which work when being used in mainland china. My plan is after I got the value of latitude and longitude I will feed them into Baidu API and get the location from there.
Many thanks.