供脚本和 DDNS 使用的公网 IP
免费 · 无需注册
一次请求,一行结果:以纯文本返回你的公网 IP 地址。专为 Shell 脚本、监控和动态 DNS 客户端设计。
$ curl https://vpnxray.com/ip
216.73.217.51
接口地址
https://vpnxray.com/ip— 服务器看到的你的 IP(如果你的连接优先使用 IPv6 则返回 IPv6,否则返回 IPv4)https://v4.vpnxray.com/ip— 始终返回你的 IPv4 地址https://v6.vpnxray.com/ip— 始终返回你的 IPv6 地址(如果你没有 IPv6,请求会失败)
也支持普通的 http://,适用于无法使用 HTTPS 的路由器和旧设备。请尽量使用 HTTPS:在普通 HTTP 下,中间的网络可能篡改返回结果。
示例
# Linux / macOS
curl https://vpnxray.com/ip
curl https://v4.vpnxray.com/ip
wget -qO- https://vpnxray.com/ip
# Windows PowerShell
(Invoke-RestMethod https://vpnxray.com/ip).Trim()
# Python 3
import urllib.request
ip = urllib.request.urlopen("https://vpnxray.com/ip").read().decode().strip()
快捷方式:用 curl 或 wget 访问 curl vpnxray.com(不带 /ip)也会返回你的 IP。
动态 DNS(DDNS)
动态 DNS 客户端需要一个返回公网 IP 的网址。使用较新版本的 ddclient:
# /etc/ddclient.conf
usev4=webv4, webv4=https://v4.vpnxray.com/ip
usev6=webv6, webv6=https://v6.vpnxray.com/ip
使用旧版本的 ddclient:
# /etc/ddclient.conf
use=web, web=https://v4.vpnxray.com/ip
使用 OpenWrt(ddns-scripts):
# /etc/config/ddns
option ip_source 'web'
option ip_url 'http://v4.vpnxray.com/ip'
在路由器或 NAS 上,找到类似“IP 检测网址”或“IP check URL”的设置项,填入 http://v4.vpnxray.com/ip。
合理使用
- 免费,无需账号,无需 API 密钥。
- 响应内容:IP 地址加一个换行符,
text/plain,从不缓存;允许跨域请求(CORS)。 - 请每分钟最多查询一次:你的 IP 很少变化。超过每分钟约 10 次请求时,服务器会返回 HTTP 429。
- 我们不保存你的 IP 地址:服务器日志只保留截短后的地址,保存 14 天(详见隐私政策)。