Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
571 views
in Technique[技术] by (71.8m points)

suddenly $_SERVER['REMOTE_ADDR'] is started returning 10.10.10.10 php

On my production site, I'm keeping the log for users when they visited my site (ie login, logout) with their IP address.I'm using $_SERVER['REMOTE_ADDR'] to get IP. It was storing accurate IP of visitor before but suddenly this variable started returning 10.10.10.10 for all of my customers.

It is happening from 01-31-2011.

What could be the causes?

server info : LAMP EDIT: Now I have below function which is also returning same 10.10.10.10

function GetIP()
{
       if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"),
"unknown"))
               $ip = getenv("HTTP_CLIENT_IP");
       else if (getenv("HTTP_X_FORWARDED_FOR") &&
strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown"))
               $ip = getenv("HTTP_X_FORWARDED_FOR");
       else if (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown"))
               $ip = getenv("REMOTE_ADDR");
       else if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] &&
strcasecmp($_SERVER['REMOTE_ADDR'], "unknown"))
               $ip = $_SERVER['REMOTE_ADDR'];
       else
               $ip = "unknown";
       return($ip);
}

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

That IP is an IANA "Black hole" address - no one is using it, and it is not considered a valid public IP address. Typically, it is used in code as a placeholder for an IP, or to mock code.

Are you certain you have not used a snippet of code somewhere that is overwriting this value? Check around for an accidental if($_SERVER['REMOTE_ADDR'] = '10.0.10.10') (note the single equals sign). In short - that address cannot possibly be legitimate.

It is, however, legit to use as an internal IP. As has been suggested by others, this may be the result of internal request routing. Check with your host to see if there have been any changes in network structure.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...