Merianos Nikos Merianos Nikos - 29 days ago 23
PHP Question

Is public IP address?

I would like to know whether there is any easy method to check whether an IP address is publicly accessible or is private.

More specifically. I know for example, that 127.0.0.1 is a private IP address that point into the same machine, 255.255.255.255 if for broadcasting into the same network, 192.168.1.0 is for local network addresses and so on. But how can I distinguish whether a given IP address is not one of the private IP and is publicly accessible?

Answer

http://en.wikipedia.org/wiki/Private_network lists the various ranges. Just construct an if statement.

Comments