-2

We have one internet line shared with multiple users and when everyone access the internet the request are sent through same remote IP. I need to find out the request is coming from which local IP. can anybody please help me to find out the local IP.

I have already written below code but it not giving the excepted result.

Thanks.

$ip = getenv('HTTP_CLIENT_IP');
var_dump($ip); 
var_Dump($_SERVER["X-FORWARDED-FOR"]);
    if (getenv('HTTP_X_FORWARDED_FOR')) {
        $pipaddress = getenv('HTTP_X_FORWARDED_FOR');
        $ipaddress = getenv('REMOTE_ADDR');
echo "Your Proxy IP address is : ".$pipaddress. "(via $ipaddress)" ;
    } else {
        $ipaddress = getenv('REMOTE_ADDR');
        echo "Your IP address is : $ipaddress";
    }
Anant Waykar
  • 662
  • 2
  • 8
  • 18
  • 3
    possible duplicate of [What is the most accurate way to retrieve a user's correct IP address in PHP?](http://stackoverflow.com/questions/1634782/what-is-the-most-accurate-way-to-retrieve-a-users-correct-ip-address-in-php) – Daan Aug 04 '14 at 14:40
  • Is your router actually exposing the internal IP? My guess would be: no. Then there's nothing you can do. It wouldn't be trustworthy anyway. – deceze Aug 04 '14 at 14:46

1 Answers1

2

Since you all share the same public IP within the local network, your router uses a technique called NAT so you can share all the same ip(s), because it can be one, or several. The relation between requests and local ip is saved in a local table in the router acting as gateway.

You CAN NOT view the local ip address behind a NAT performing router. It is not a NAT problem, it is Internet addressing and packet header limitation, nothing to do with configurations you could deal with.

If this is a corporate trouble, you could do it placing the server in your local network and in that case, the $_SERVER['REMOTE_ADDR'] value will be the local IP address you are looking for.

Gestudio Cloud
  • 290
  • 2
  • 12