`

通过网络服务获取本地的外网IP地址

阅读更多

      想要在Linux环境下,通过网络服务获取本地的外网IP地址,找了几个可用的记录于此:

      1. http://www.cip.cc/

      使用方式:

命令行查询(详细):

UNIX/Linux: #curl cip.cc
Windows: >telnet cip.cc
                >ftp cip.cc

命令行查询(纯ip):

UNIX/Linux: #curl ip.cip.cc

 

      如果是返回详细信息,类似:

IP : X.X.X.X
地址 : 中国 XX省 XX市
运营商 : XX

数据二 : XX省XX市XX区 | XX运营商

URL : http://www.cip.cc/IP地址

 

      2. http://ip.cn/

      使用方式:

# curl ip.cn

       返回信息:

当前 IP:X.X.X.X 来自:XX省XX市 XX运营商

 

      3. http://ifconfig.me/

      使用方式类似:

$ curl ifconfig.me ⇒ IP地址
$ curl ifconfig.me/ip ⇒ IP地址
$ curl ifconfig.me/host ⇒
$ curl ifconfig.me/ua ⇒ Mozilla/5.0 (Windows NT 6.2; rv:39.0) Gecko/20100101 Firefox/39.0
$ curl ifconfig.me/port ⇒ 端口
$ curl ifconfig.me/lang ⇒ en-US,en;q=0.5
$ curl ifconfig.me/keepalive ⇒
$ curl ifconfig.me/connection ⇒ keep-alive
$ curl ifconfig.me/encoding ⇒ gzip, deflate
$ curl ifconfig.me/mime ⇒ text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
$ curl ifconfig.me/charset ⇒
$ curl ifconfig.me/via ⇒
$ curl ifconfig.me/forwarded ⇒
$ curl ifconfig.me/all ⇒ 所有检测信息
$ curl ifconfig.me/all.xml ⇒ XML格式的所有检测信息
$ curl ifconfig.me/all.json ⇒ JSON格式的所有检测信息

 

      4. http://ipinfo.io/

      使用方式:

$ curl ipinfo.io

       返回信息类似:

{
   "ip": "X.X.X.X",
   "hostname": "No Hostname",
   "city": "XX",
   "region": "XX",
   "country": "XX",
   "loc": "经纬度",
   "org": "详细地址"
}

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics