开发者_StackOverflowWhen I go to http://www.whatismyip.com/ I get an IP address of 203.39.136.200 but if I use php/apache I get:
HTTP_CLIENT_IP = ""
HTTP_FORWARDED_FOR = ""
REMOTE_ADDR = 10.15.60.84 //IP of my machine
We are introducing geo-sensitive content into one of our sites and have the necessary lookup Web Services ready to go but as you can imagine using the local IP of the machine (10.15.60.84)
produces no results so I need to work out a way to retrieve 203.39.136.200
.
Cheers Rob
If you are accessing the server from the local network then you will get the local address, even if you access the server using an address bound to an external interface. You can get around this by adding routing rules to your default gateway to route packets to the remote side of the Internet link your company uses, but this will cause extra traffic on the link since the packets will now have to go across it to get outside and then back in again.
精彩评论