IP到国家 - IPv6

时间:2012-01-30 07:59:32

标签: ipv6 ip-geolocation

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

我目前正在更新这个,并且我想问一下IPv6是否有将IPv6转换为国家/地区的解决方案?

注意:首选PHP和MySQL

THX

4 个答案:

答案 0 :(得分:5)

如果您使用网络服务即可,那么我的服务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响应以获取国家/地区,也可以将国家/地区添加到网址:

$ curl http://ipinfo.io/2001:4860:4860::8888/country
US

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

答案 1 :(得分: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"
}⏎ 

答案 2 :(得分:2)

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

答案 3 :(得分:0)

一种简单的方法是使用IP地理位置API,例如我的服务https://astroip.co,它同时支持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"
}

您可以在https://astroip.co/docs

中找到更多详细信息
相关问题