Problem to get my real ip on iOS

Hello :slight_smile:

I have a really problem to get my real IP on iOS. When I’m on Safari iOS, my script return this ip :

248.17.., but my real ip is : 91.17*..

On Windows 10 i don’t have problem.

If I go to on iOS he display my real Ip.

I didn’t understand…

My PHP function :

function getRemoteAddr()
    if(getenv('HTTP_CLIENT_IP'))            return getenv('HTTP_CLIENT_IP');
    elseif(getenv('HTTP_X_FORWARDED_FOR'))  return getenv('HTTP_X_FORWARDED_FOR');
    elseif(getenv('HTTP_X_FORWARDED'))      return getenv('HTTP_X_FORWARDED');
    elseif(getenv('HTTP_FORWARDED_FOR'))    return getenv('HTTP_FORWARDED_FOR');
    elseif(getenv('HTTP_FORWARDED'))        return getenv('HTTP_FORWARDED');
    elseif(getenv('REMOTE_ADDR'))           return getenv('REMOTE_ADDR');
    else    return null;

The reason why you are getting a different IP address on Safari iOS compared to Windows 10 is likely due to the way that the network is configured on the iOS device.

It’s possible that the IP address you are seeing on iOS is the IP address of a proxy or intermediate server that is forwarding the request on to your server. This is why you are seeing a different IP address than your actual IP address.

In your PHP function, you are checking several different server variables to try and determine the client’s IP address. However, the order in which these variables are checked may not be optimal for all scenarios.

Here’s a modified version of your function that checks the server variables in a more optimal order, based on common proxy configurations:

function getRemoteAddr()
    $remoteAddr = null;
    if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
        $ipAddresses = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
        $remoteAddr = trim(end($ipAddresses));
    } elseif(isset($_SERVER['HTTP_CLIENT_IP'])) {
        $remoteAddr = $_SERVER['HTTP_CLIENT_IP'];
    } else {
        $remoteAddr = $_SERVER['REMOTE_ADDR'];
    return $remoteAddr;

Yes, but why is it that on all sites they show the correct IP (on iOS), but I don’t.

Even that might not might be a fix as the IP (on iOS) might be getting another server’s IP before it gets the actual IP. I’m not a hacker, but I would suspect that is how people with hacking skills and VPN masks the real IPs.

If i go on this little real site website :

It’s show my real IP. He don’t use script so…

Sponsor our Newsletter | Privacy Policy | Terms of Service