通过网络服务获取本地的外网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": "详细地址"
}

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值