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.
Bu
geolocation is bad, mmkay? the internet is location-agnostic, and i have never seen geolocation used for something non-trivial-non-evil. that is, the only good applications i've seen (language selection) were trivial (could just as easily be a dropdown). many evil applications exist (this video not available in your country, targeting my physical location for ads and tracking) we can't discourage something like this from existing, but we should push to make it illegal or at least socially unacceptable to use.
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."
maxmind.com's geolocation services and libraries handle IPv6 OK. Maybe their stuff is an option for you. (I don't have any affiliation with them.)
If you read a number of ipv6, address and transition mechanism on wiki, you will find a few IPv6 addresses patterns that may infer an ipv4 (siit, ipv4-mapped ipv6, nat64, the 2002:* thing written above, etc.). One of them to start: http://en.wikipedia.org/wiki/IPv6_transition_mechanisms
I would not count on these schemes to be popular enough to do the usual geo reports, fraud protection, or incident detection, but I would definitely give precedence to an ipv4 geo lookup for such inferred ipv4 addresses over an ipv6 geo lookup (assuming the ipv4 db is more complete).
My concern with ipv6 geo information is the incredibly large number of subnets. Databases will get larger (more ip ranges), that is expected but for the same amount of terminal geo information, the databases will be sparser and the deeper tree is also longer to iterate (for implementation that uses binary or radix trees) which implies some performance cost. Geo databases using sql tables with ip ranges will probably also suffer, since we don't have big-bigint of 128bits, that I know of, to use arithmetic.
Another concern is the mobiles: ipv6 is designed to facilitate roaming, if I am not mistaking. You could change cell towers and keep your IP. maybe even while changing city, region or country. I somewhat doubt that since that a strong address affinity was the purpose of a MAC address. Ip addresses exist precisely for routing purpose, but I think it is fair to mention they could become invariant enough to cripple the accuracy of geo location, obviously.
I feel the collaboration of user agents/browsers at the application layer (some geo location header for example) is likely the future, even if this can be spoofed by mischievous people.
There is a protocol called Referral Whois which allows providers to publish IP geolocation information and others to retrieve it.
For example, my current IP 2001:470:b4ea:babe:d57:15c8:97b:60c9 belongs to Hurricane Electric in the US. The actual server where the IPv4-IPv6 tunnel I use terminates is in Switzerland, but I am in Austria. HE publishes all of this, so if you enter the IP in a tool supporting RWhois like this, you will find the contact data of HE and somwhere near the bottom you see
contact:Name:Private Customer - Hurricane Electric
contact:Street-Address:Private Residence
contact:Country-Code:AT
which is my location.
Not many providers do publish that, and not many geolocation tools support it, but at least it exists.
Most of the IP geolocation providers (of those who support IPv6, some still don't) put this IP to Switzerland, some even in the US.