0

I can only access the internet from my place from behind a NAT and a proxy. This site however also shows my machine's private LAN address, as well as my NAT's public address. They are apparently using javascript in the process, but I can only find code where they set the value, but not how they find it. So, how can we find out the private IP address of a client machine using javascript?

apoorv020
  • 5,420
  • 11
  • 40
  • 63

2 Answers2

3

They're using Java for that:

<span class="pbb" id="lanip"><b>Router IP Address Testing...</b></span>
<script>
function MyAddress(IP)
{ document.getElementById("lanip").innerHTML = IP; }
</script>
<applet code="MyAddress.class" MAYSCRIPT width=0 height=0>
You Need To Enable Java For This To Work
</applet> 
BMitch
  • 231,797
  • 42
  • 475
  • 450
  • but I think this code only updates the value inside the html element that is displayed. That still leaves the question, how do they detect the ip address? – apoorv020 Mar 20 '11 at 20:12
  • 1
    The MyAddress.class applet is doing it, which is Java code. Disable Java and it likely won't work. Here's a thread discussing the java code: http://www.exampledepot.com/egs/java.net/Local.html – BMitch Mar 20 '11 at 21:21
1

Are you sure you're behind just a NAT router? If you're behind a proxy, the proxy might well be adding an X-Forwarded-For header.

dty
  • 18,795
  • 6
  • 56
  • 82
  • I'm behind at least one NAT, maybe more. The page does say transparent proxy detected, but the proxy address it shows is my public IP address, instead of the private proxy I use in the browser. – apoorv020 Mar 20 '11 at 19:55
  • Yup, the proxy is sending `X-forwarded-for` in the header. Just checked using http://www.ericgiguere.com/tools/http-header-viewer.html. – apoorv020 Mar 21 '11 at 04:38