How can a server find real client IP address?

2019-01-20 19:06发布

问题:

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?

回答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.



回答2:

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>