在终端查看您的 IP

一条命令即可输出互联网看到的您的地址。简短路径以纯文本返回国家、城市、网络和时区,一个 JSON 响应则包含全部信息。无需注册,无需密钥。

$ curl fpleak.com
203.0.113.42
$ curl fpleak.com/country
Netherlands
$ curl fpleak.com/asn
AS64500

命令及其返回内容

命令 返回 您的结果
curl fpleak.com
您的 IP 地址 203.0.113.42
curl fpleak.com/country
国家名称 Netherlands
curl fpleak.com/country-iso
两位字母国家代码 NL
curl fpleak.com/city
城市(近似) Amsterdam
curl fpleak.com/asn
自治系统号 AS64500
curl fpleak.com/org
组织或运营商 Example Networks
curl fpleak.com/tz
时区 Europe/Amsterdam
curl fpleak.com/ip.json
以上全部内容(JSON) JSON

curl 和 wget

纯 HTTP 即可使用,无需任何参数,也无需跟随重定向。返回一行文本。

curl fpleak.com
wget -qO- fpleak.com

PowerShell

Windows 上无需安装任何东西。请使用明确的路径:它们对任何客户端都返回纯文本。

irm fpleak.com
irm fpleak.com/ip.json

Python

标准库就够了,无需安装任何包。

python -c "import urllib.request as u; print(u.urlopen('https://fpleak.com/ip').read().decode().strip())"

JSON 和 jq

只取脚本需要的那个字段。

curl -s fpleak.com/ip.json | jq -r .country_code

检查 VPN 切换

在开启隧道前后各查询一次,对比两次的结果。

before=$(curl -s fpleak.com)
# turn the VPN on, then run:
after=$(curl -s fpleak.com)
[ "$before" = "$after" ] && echo "same address: $after" || echo "changed: $before to $after"

监控变动的地址

适用于使用动态 IP 的家庭服务器:通过 cron 运行,输出新地址时再采取行动。

ip=$(curl -s fpleak.com)
[ "$ip" != "$(cat ~/.last_ip 2>/dev/null)" ] && echo "$ip" > ~/.last_ip && echo "new address: $ip"

须知

  • 每个响应描述的都是发起请求的那个地址。您无法查询别人的地址,因此没有可供抓取的内容。
  • 响应为纯文本,每项一行。如果对某个地址一无所知,该路径会返回 404 和文本 Not available。
  • 这些路径支持 HTTP 和 HTTPS。在 VPN 或代理之后,您得到的是其出口地址,这正是您需要检查的。
  • 城市来自地理位置数据库,是近似值。国家和网络通常是准确的。
  • 如果脚本请求过于频繁,服务器会返回 429 和 Retry-After 请求头。等待相应的秒数后再请求。

需要的不只是地址?

浏览器测试还会读取指纹、WebRTC、DNS、TLS 和行为信号,并显示您的环境看起来有多一致。

打开完整测试

IP Geolocation by DB-IP