Hello,
In my personal PHP application, I like to identify visitors to my website by checking the IP range
that their IP address falls into. This is easy enough for IPv4 when I have the CIDR.
For IPv6 however it is another matter entirely, because at present I don't know
how to match an IPv6 address. As a result I am using the cumbersome substr matching
approach, which does not work for many addresses.
For example, consider 2620:149:f01:2b0:99ad:f010:61c1:63c5.
The CIDR is 2620:149::/36. The 0 nybble in the 3rd 32-bit word is implied most of the time
and this breaks the substr approach.
Surely there is by now a simple way to do this.
Can someone tell me the best solution that exists at present?
Thanks.