I've been using an IPv4 to country convertor successfully. eg: get IP of machine and compare to table to get country.
I'm updating this currently and with IPv6 around the corner I wanted to ask if there is a solution for converting IPv6 to country?
Note: preference for PHP and MySQL
thx
Adoption of IPv6 has been delayed in part due to network address translation (NAT), which takes private IP addresses and turns them into public IP addresses.
Google offers their Geolocation API and Geocoding API that can perform geolocation based on IPv4 or IPv6 addresses and Google Maps has a wide variety of application integrations. Just like all IPv6 location systems, they have had challenges and are constantly making improvements to the accuracy of their systems.
The main advantage of IPv6 over IPv4 is its larger address space. The size of an IPv6 address is 128 bits, compared to 32 bits in IPv4. The address space therefore has 2128=340,282,366,920,938,463,463,374,607,431,768,211,456 addresses (approximately 3.4×1038).
If you're OK with using a web service then my service http://ipinfo.io recently added IPv6 support:
$ curl http://ipinfo.io/2001:4860:4860::8888
{
"ip": "2001:4860:4860::8888",
"hostname": "No Hostname",
"city": null,
"region": null,
"country": "US",
"loc": "38.0000,-97.0000",
"org": "AS15169 Google Inc."
}
You can either parse the JSON response to get the country, or add country to the URL:
$ curl http://ipinfo.io/2001:4860:4860::8888/country
US
See http://ipinfo.io/developers for more details.
Maxmind have support for IPv6 in their GeoIP Country database.
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