Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IP to Country - IPv6 [closed]

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

like image 950
Adam Avatar asked Jan 30 '12 07:01

Adam


People also ask

Why has the world not changed to IPv6 by now?

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.

Does IPv6 have geolocation?

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.

How many IPv6 addresses are left?

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


2 Answers

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.

like image 58
Ben Dowling Avatar answered Sep 25 '22 02:09

Ben Dowling


Maxmind have support for IPv6 in their GeoIP Country database.

like image 44
Emil Vikström Avatar answered Sep 23 '22 02:09

Emil Vikström