路漫漫其修远兮,吾将上下而求索

导航

命令行获取公网ip

curl http://httpbin.org/ip
curl httpbin.org/ip

curl ifconfig.me
image

最稳定推荐(2025实测)

curl icanhazip.com
curl ipinfo.io/ip

备选方案(全球节点多)

curl ifconfig.me
curl ipecho.net/plain
curl wgetip.com
image

curl cip.cc
image
curl cip.cc | grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}'
image

需要地理位置、运营商等元数据时使用:

curl ipinfo.io/json
image
yum install jq
curl ipinfo.io/json | jq '{ip, city, org, timezone}'
image
windows系统命令行
image
PS:地址仅供参考,不太准

当服务器未安装curl/wget时的应急方案(DNS协议查询):

yum install bind-utils 安装dig命令所在工具包
dig +short myip.opendns.com @resolver1.opendns.com
image

测试代理链路的出口IP:

curl -x socks5://127.0.0.1:1080 ipinfo.io/ip 1080替换为你的代理端口
image
没开代理软件时不存在端口就会失败
image

curl cip.cc
image
curl cip.cc | grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}'
image

最后几点:

image

参考:
获取公网IP命令大全 - mdnice 墨滴 获取公网IP命令大全 - mdnice 墨滴

posted on 2025-09-12 15:29  爱在西元间  阅读(22)  评论(0)    收藏  举报