背景
在自己的笔记本上面装Linux,上网一般都是通过wifi上面,不是直接配置外网IP的,有时候连接到远程服务器的时候,需要知道自己的外网IP的哪个,进行添加白名单。
i
这个网站提供了,对应的api来获取对应的外网IP信息,及请求客户端的信息,可以通过浏览器访问i找到下面的命令帮助,执行对应的curl请求,就可以获取到信息
$ curl i ⇒ 1.62.24.94 $ curl i/ip ⇒ 1.62.24.94 $ curl i/host ⇒ unavailable $ curl i/ua ⇒ Mozilla (X11; Linux x86_64) AppleWebKi (KHTML, like Gecko) Chrome Safari $ curl i/port ⇒ 15294 $ curl i/lang ⇒ zh-CN,zh;q=0.9,en;q=0.8 $ curl i/keepalive ⇒ $ curl i/connection ⇒ $ curl i/encoding ⇒ gzip, deflate, br $ curl i/mime ⇒ text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3 $ curl i/charset ⇒ $ curl i/via ⇒ 1.1 google $ curl i/forwarded ⇒ 1.62.24.94, 213.62.20.194 $ curl i/all ⇒ ip_addr: 1.62.24.94 remote_host: unavailable user_agent: Mozilla (X11; Linux x86_64) AppleWebKi (KHTML, like Gecko) Chrome Safari port: 15294 language: zh-CN,zh;q=0.9,en;q=0.8 referer: connection: keep_alive: method: GET encoding: gzip, deflate, br mime: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3 charset: via: 1.1 google forwarded: 1.62.24.94, 213.62.20.194 $ curl i/all.xml ⇒ <info> <ip_addr>1.62.24.94</ip_addr> <remote_host>unavailable</remote_host> <user_agent>Mozilla (X11; Linux x86_64) AppleWebKi (KHTML, like Gecko) Chrome Safari</user_agent> <port>15294</port> <language>zh-CN,zh;q=0.9,en;q=0.8</language> <referer></referer> <connection></connection> <keep_alive></keep_alive> <method>GET</method> <encoding>gzip, deflate, br</encoding> <mime>text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3</mime> <charset></charset> <via>1.1 google</via> <forwarded>1.62.24.94, 213.62.20.194</forwarded> </info> $ curl i/all.json ⇒ {"ip_addr":"1.62.24.94","remote_host":"unavailable","user_agent":"Mozilla (X11; Linux x86_64) AppleWebKi (KHTML, like Gecko) Chrome Safari","port":15294,"language":"zh-CN,zh;q=0.9,en;q=0.8","referer":"","method":"GET","encoding":"gzip, deflate, br","mime":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3","via":"1.1 google","forwarded":"1.62.24.94, 213.62.20.194"}ip.cn
上面的网址提供的内容虽然很多,但是比较慢,有时候还请求失败,可以使用ip.cn提供的服务进行查询
curl{"ip": "112.48.22.57", "country": "福建省厦门市", "city": "移动"}