I'm working on an IP geolocation library that uses the first three octets of an IPv4 address to determine a user's country, city, lat, lon, etc. Works like a charm.
But it doesn't handle IPv6 addresses, and I'd like it to do so.
Is there any way to transform an IPv6 address to get the equivalent of the first three octets of an IPv4 address, or are they on an entirely different numbering scheme, requiring a completely different ipgeo mapping?
Yes, IPv6 geoloaction is supported as well.
The researchers tested various geolocation database downloads for the accuracy of their country-level geolocation data and found that compared to IPv4 addresses that are 90% accurate at the country level, IPv6 addresses are only 40–60% accurate.
FBI, Drug Enforcement Administration, and Royal Canadian Mounted Police officials have told industry representatives that IPv6 traceability is necessary to identify people suspected of crimes. The FBI has even suggested that a new law may be necessary if the private sector doesn't do enough voluntarily.
The typical IPv6 allocation is a /32 (four octets) to an Internet provider (which can be a multinational company), then /48 (six octets) to an end site (typically a client organization). You can get a starting point in the IANA list of delegated blocks.
This is only for
registrations found in the databases of the RIR. Assignment to end
users is typically not recorded so, my current address,
2a01:e35:8bd9:8bb0:92b:8628:5ca5:5f2b
will tell you only that my
provider's headquarters are in Paris (since it is a national company,
the clients can be anywhere in France).
Another exception is the PI (Provider-Independent) assignements, which are typically /48.
Also, there exists many databases of geolocation for IPv4 and, to my knowledge, none for IPv6. You will have to do everything yourself.
To summary: more work than you apparently believe.
Friendly correction to Noah's comment (Jun 3 at 7:57)--
Per MaxMind's client services department (emphasis mine): "IPv6 is currently NOT supported. At some time in the future, we do plan to implement it but we do not have a date at this time."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With