利用命令行工具curl获取公网ip地址

一个是:

curl  ifconfig.me

 

另一个是:

curl  ipinfo.io

这个输出的信息很丰富,如城市,地区,国家,经纬度等都能显示,如下面:

{
  "ip": "223.68.142.242",
  "hostname": "No Hostname",
  "city": null,
  "region": null,
  "country": "CN",
  "loc": "35.0000,105.0000",
  "org": "AS56046 China Mobile communications corporation"
}

另外如果查询的时候在ipinfo.io后加上特定ip地址,输出的是这个ip的信息,eg:

curl  ipinfo.io/202.65.246.80

则输出:

{
  "ip": "202.65.246.80",
  "hostname": "No Hostname",
  "city": "Singapore",
  "region": "00",
  "country": "SG",
  "loc": "1.2931,103.8558",
  "org": "AS4773 MobileOne Ltd. Mobile/Internet Service Provider Singapore"
}

 

posted @ 2014-11-20 15:33  venid  阅读(3172)  评论(0编辑  收藏  举报