Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
IP到国家/地区-IPv6_Ipv6_Ip Geolocation - Fatal编程技术网

IP到国家/地区-IPv6

IP到国家/地区-IPv6,ipv6,ip-geolocation,Ipv6,Ip Geolocation,我已经成功地使用了IPv4到国家/地区转换器。 例如:获取机器的IP并与表进行比较以获取国家/地区 我现在正在更新这个,随着IPv6即将到来,我想问一下,是否有一种将IPv6转换为国家/地区的解决方案 注意:首选PHP和MySQL thx在其GeoIP国家/地区数据库中支持IPv6。如果您同意使用web服务,则我的服务最近添加了IPv6支持: $ curl http://ipinfo.io/2001:4860:4860::8888 { "ip": "2001:4860:4860::8888"

我已经成功地使用了IPv4到国家/地区转换器。 例如:获取机器的IP并与表进行比较以获取国家/地区

我现在正在更新这个,随着IPv6即将到来,我想问一下,是否有一种将IPv6转换为国家/地区的解决方案

注意:首选PHP和MySQL


thx在其GeoIP国家/地区数据库中支持IPv6。

如果您同意使用web服务,则我的服务最近添加了IPv6支持:

$ 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:

$ curl http://ipinfo.io/2001:4860:4860::8888/country
US
有关更多详细信息,请参阅。

下面是一个示例

{
    "ip": "2c0f:fd58:9:198::255e",
    "city": "",
    "region": "",
    "country_name": "South Africa",
    "country_code": "ZA",
    "continent_name": "Africa",
    "continent_code": "AF",
    "latitude": -29.0,
    "longitude": 24.0,
    "asn": "AS20940",
    "organisation": "Akamai International B.V.",
    "postal": "",
    "currency": "ZAR",
    "currency_symbol": "R",
    "calling_code": "27",
    "flag": "https://ipdata.co/flags/za.png",
    "time_zone": "Africa/Johannesburg"
}⏎ 

一种简单的方法是使用像my service这样的IP地理定位API:它支持IPv4和IPv6

电话:

https://api.astroip.co/2c0f:fd58:9:198::255e/?api_key=1725e47c-1486-4369-aaff-463cc9764026
返回:

{
  "status_code": 200,
  "geo": {
    "is_metric": true,
    "is_eu": false,
    "longitude": 24,
    "latitude": -29,
    "country_geo_id": 953987,
    "zip_code": null,
    "city": null,
    "region_code": null,
    "region_name": null,
    "continent_code": "AF",
    "continent_name": "Africa",
    "capital": "Pretoria",
    "country_name": "South Africa",
    "country_code": "ZA"
  },
  "asn": {
    "route": "2c0f:fd58::/32",
    "name": "Vox-Telecom",
    "type": "isp",
    "domain": "voxtelecom.co.za",
    "organization": "Vox-Telecom",
    "asn": "AS11845"
  },
  "currency": {
    "native_name": "Suid-Afrikaanse rand",
    "code": "ZAR",
    "name": "South African Rand",
    "symbol": "R"
  },
  "timezone": {
    "is_dst": false,
    "gmt_offset": 7200,
    "date_time": "2020-11-23T22:59:29+02:00",
    "microsoft_name": "South Africa Standard Time",
    "iana_name": "Africa/Johannesburg"
  },
  "security": {
    "is_crawler": false,
    "is_proxy": false,
    "is_tor": false,
    "tor_insights": null,
    "proxy_insights": null,
    "crawler_insights": null
  },
  "crypto": null,
  "user_agent": null,
  "error": null,
  "ip_type": "ipv6",
  "ip": "2c0f:fd58:9:198::255e"
}

您可以在

上找到更多详细信息。请注意,所有地理ip数据库都是近似值,遗憾的是,IPv6数据的质量仍然比IPv4数据的质量差得多。我在您之前发布了一个非常类似的问题。我现在用我找到的答案来回答它。以下是链接:Maxmind声称他们的geo city数据库准确率为99.8%。即使那不是真的,我想如果你只是想得到国家代码,你还是应该没事的。您可以下载免费版本的geoip数据库或付费版本。您需要购买更新以使表保持最新。出于同样的原因,我目前正在测试ipv6数据库。如果无法使用,我会告诉您。IP2Location Lite数据库也支持IPv6。
{
  "status_code": 200,
  "geo": {
    "is_metric": true,
    "is_eu": false,
    "longitude": 24,
    "latitude": -29,
    "country_geo_id": 953987,
    "zip_code": null,
    "city": null,
    "region_code": null,
    "region_name": null,
    "continent_code": "AF",
    "continent_name": "Africa",
    "capital": "Pretoria",
    "country_name": "South Africa",
    "country_code": "ZA"
  },
  "asn": {
    "route": "2c0f:fd58::/32",
    "name": "Vox-Telecom",
    "type": "isp",
    "domain": "voxtelecom.co.za",
    "organization": "Vox-Telecom",
    "asn": "AS11845"
  },
  "currency": {
    "native_name": "Suid-Afrikaanse rand",
    "code": "ZAR",
    "name": "South African Rand",
    "symbol": "R"
  },
  "timezone": {
    "is_dst": false,
    "gmt_offset": 7200,
    "date_time": "2020-11-23T22:59:29+02:00",
    "microsoft_name": "South Africa Standard Time",
    "iana_name": "Africa/Johannesburg"
  },
  "security": {
    "is_crawler": false,
    "is_proxy": false,
    "is_tor": false,
    "tor_insights": null,
    "proxy_insights": null,
    "crawler_insights": null
  },
  "crypto": null,
  "user_agent": null,
  "error": null,
  "ip_type": "ipv6",
  "ip": "2c0f:fd58:9:198::255e"
}