2

I'm calling $_SERVER["REMOTE_ADDR"] and it returns '::1'

Any ideas why am I getting this strange output? How to get a proper ip?

skyisred
  • 6,855
  • 6
  • 37
  • 54

1 Answers1

6

::1 is the IPv6 equivalent of 127.0.0.1 which is the IP address of your local (loopback) interface.

More information here: http://en.wikipedia.org/wiki/Localhost

How to get a proper ip?

You can disable IPv6 in your webserver to only serve IPv4 hosts. This way, you will only get propers IP adresses in $_SERVER["REMOTE_ADDR"]

Pierre-Olivier
  • 3,104
  • 19
  • 37
  • Does it mean that outside of localhost this will return a traditional ip? – skyisred Mar 27 '12 at 19:06
  • If your production webserver is accessible via IPv6 and someone with an IPv6 connection visits your website, no. There is no need to treat IPv6 addresses differently, it is just encoded in 64 bits instead of 32. You do not need to modify anything on your side. In fact, you should get used to it because IPv6 is going to be the next standard on the internet. – Pierre-Olivier Mar 27 '12 at 19:08