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
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.