Question

I want to obtain the remote client ip by javascript, not querying any external ip resource pools. how could i get the remote ip address, just like the way i get appName by navigator.appName

also like the ways as follows:

PHP:<?php echo $_SERVER["REMOTE_ADDR"]; ?>

NODE.JS: req.connection.remoteAddress

so green with javascript, and im trying to google with some keywords. yet i still can't find the result i want. any guy here could share his solution of the same desired scene? any tips or suggestions are welcome.

platform:chrome, firefox

Was it helpful?

Solution

You can't know it on the client because the client doesn't know it. For example, if the client is behind a NAT, the IP of the machine will be different from the IP the "world" sees.

Make a simple server (AJAX) call that will return you the remote address.

OTHER TIPS

This is not possible using pure Javascript without external calls.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top