8

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

我目前正在更新此内容,并且 IPv6 即将到来我想问是否有将 IPv6 转换为国家/地区的解决方案?

注意:偏好 PHP 和 MySQL

谢谢

4

4 回答 4

7

如果您可以使用 Web 服务,那么我的服务http://ipinfo.io最近添加了 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

有关详细信息,请参阅http://ipinfo.io/developers 。

于 2014-08-30T15:59:12.293 回答
3

Maxmind在其 GeoIP Country 数据库中支持 IPv6。

于 2012-01-30T08:03:28.190 回答
3

这是https://ipdata.co的示例

curl https://api.ipdata.co/2c0f:fd58:9:198::255e?api-key=test

这使

{
    "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"
}⏎ 
于 2017-11-06T17:08:07.280 回答
0

An easy way is to use an IP Geolocation API like my service: https://astroip.co which supports both IPv4 and IPv6.

Calling:

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

Returns:

{
  "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"
}

You can find more details on https://astroip.co/docs

于 2020-11-23T21:02:56.103 回答