用 curl 一行命令查公网 IP

终端里直接显示路由器或 VPN 出口的公网 IP,不用打开浏览器。

Linuxcurl 请求网络命令行低风险
运行 curl -s https://api.ipify.org 即可打印公网 IP;想测 IPv6 就用 curl -s https://api64.ipify.org。

01命令

命令
$ curl -s https://api.ipify.org

02作用说明

-s 参数让 curl 不显示进度条,只输出 IP 本身,方便写进脚本或命令行提示符。ipify 是一个轻量回显服务,返回的就是这次请求到达服务器时使用的地址,也就是外部网站看到的你的出口 IP。如果多次查询结果不同,说明运营商用的是动态 IP,或者 VPN 在轮换出口节点。

03风险

风险低风险
使用条件curl; internet access
!注意: 查询时你的公网 IP 会记录在服务方的日志里,这是所有 IP 回显服务的固有行为;除此之外不会发送任何数据。

04撤销

✓无需撤销——该命令不会改变持久状态。

05来源

  • curl(1) — Ubuntu man page
    Ubuntu manpages · community · 2026-09-17
    依据: Man page text contains -s (silent mode) and -o (write output to file) option descriptions, confirming the flags used in the command.
  • curl(1) — Linux man page
    man7.org · community · 2026-09-17
    依据: Documents '-s/--silent' (silent or quiet mode, don't show progress meter) and '-o/--output'; confirms the '-s' flag text on the page.

最后验证: 2026-09-19 · 分类: 网络

06相关方案