IP到国家/地区-IPv6 [英] IP to Country - IPv6
问题描述
我一直在成功使用IPv4到国家/地区转换器. 例如:获取机器的IP并与表格进行比较以获取国家/地区.
I've been using an IPv4 to country convertor successfully. eg: get IP of machine and compare to table to get country.
我目前正在对此进行更新,我想问一下是否有将IPv6转换为国家/地区的解决方案?
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?
注意:偏好使用PHP和MySQL
Note: preference for PHP and MySQL
thx
推荐答案
如果您可以使用Web服务,那么我的服务 http ://ipinfo.io 最近添加了IPv6支持:
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."
}
您可以解析JSON响应以获取国家/地区,也可以将国家/地区添加到URL:
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
有关更多详细信息,请参见 http://ipinfo.io/developers .
See http://ipinfo.io/developers for more details.
这篇关于IP到国家/地区-IPv6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!