想要在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
如果是返回詳細信息,類似:
地址 : 中國 XX省 XX市
運營商 : XX
數據二 : XX省XX市XX區 | XX運營商
URL : http://www.cip.cc/IP地址
2. http://ip.cn/
使用方式:
返回信息:
3. http://ifconfig.me/
使用方式類似:
$ 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/
使用方式:
返回信息類似:
"ip": "X.X.X.X",
"hostname": "No Hostname",
"city": "XX",
"region": "XX",
"country": "XX",
"loc": "經緯度",
"org": "詳細地址"
}