参考自:http://www.gaojinbo.com/linux%E5%86%85%E7%BD%91ip%E7%9A%84%E6%9C%BA%E5%99%A8%E5%A6%82%E4%BD%95%E6%9F%A5%E7%9C%8B%E6%9C%AC%E5%9C%B0%E5%A4%96%E7%BD%91ip.html
非常简单,下面一条命令搞定
curl ifconfig.me
完成!
更多命令以及返回结果如下:
Command Line Interface
$ curl ifconfig.me |
⇒ |
221.7.252.66 |
$ curl ifconfig.me/ip |
⇒ |
221.7.252.66 |
$ curl ifconfig.me/host |
⇒ |
|
$ curl ifconfig.me/ua |
⇒ |
Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.79 Safari/535.11 QIHU THEWORLD |
$ curl ifconfig.me/port |
⇒ |
31255 |
$ curl ifconfig.me/lang |
⇒ |
zh-CN,zh;q=0.8 |
$ curl ifconfig.me/keepalive |
⇒ |
|
$ curl ifconfig.me/connection |
⇒ |
keep-alive |
$ curl ifconfig.me/encoding |
⇒ |
gzip,deflate,sdch |
$ curl ifconfig.me/mime |
⇒ |
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 |
$ curl ifconfig.me/charset |
⇒ |
GBK,utf-8;q=0.7,*;q=0.3 |
$ curl ifconfig.me/via |
⇒ |
|
$ curl ifconfig.me/forwarded |
⇒ |
|
$ curl ifconfig.me/all |
⇒ |
ip_addr: 221.7.252.66
remote_host:
user_agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.79 Safari/535.11 QIHU THEWORLD
port: 31255
lang: zh-CN,zh;q=0.8
connection: keep-alive
keep_alive:
encoding: gzip,deflate,sdch
mime: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
charset: GBK,utf-8;q=0.7,*;q=0.3
via:
forwarded:
|
$ curl ifconfig.me/all.xml |
⇒ |
<info>
<charset>GBK,utf-8;q=0.7,*;q=0.3</charset>
<connection>keep-alive</connection>
<encoding>gzip,deflate,sdch</encoding>
<forwarded></forwarded>
<ip_addr>221.7.252.66</ip_addr>
<keep_alive></keep_alive>
<lang>zh-CN,zh;q=0.8</lang>
<mime>text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8</mime>
<port>31255</port>
<remote_host></remote_host>
<user_agent>Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.79 Safari/535.11 QIHU THEWORLD</user_agent>
<via></via>
</info>
|
$ curl ifconfig.me/all.json |
⇒ |
{"connection":"keep-alive","ip_addr":"221.7.252.66","lang":"zh-CN,zh;q=0.8","remote_host":"","user_agent":"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.79 Safari/535.11 QIHU THEWORLD","charset":"GBK,utf-8;q=0.7,*;q=0.3","port":"31255","via":"","forwarded":"","mime":"text/html,application/x |