Alex Rivera | Logout

Geolocation with IPv6?

Asked 2009-07-22T01:55:17.727
21

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?

Edit
Report

3 Answers

2

IPv6 uses a completely different addressing scheme compared to IPv4. There is no way you can map IPv6 addresses to IPv4 addresses, with one exception. If you see IPv6 addresses that start with 2002: then the address is a 6to4 address. You won't see a lot of those in use probably and they are being deprecated, but those are mappable to IPv4.

Each user of a public IPv4 address can use a /48 (65536 subnets) of IPv6 space. Those addresses always begin with 2002: and the next two hexadecimal numbers are the IPv4 address. So 2002:5389:1164: corresponds to my own webserver's IPv4 address (83.137.17.100):

0x53 = 83
0x89 = 137
0x11 = 17
0x64 = 100

But all 'normal' IPv6 addresses are completely unrelated to any IPv4 addresses. At least in a standard way. An ISP could define a relationship between IPv4 and IPv6 addresses when rolling out IPv6 to its customers. But you won't know about that relationship so it will be useless to you...

answered 2011-06-26T14:58:50.287
1

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

answered 2010-06-03T07:57:12.977
-2

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.

answered 2011-02-08T04:59:06.387

Your Answer