VPNXray
繁體中文

給腳本與 DDNS 使用的公用 IP

免費 · 免註冊

一次請求,一行結果:以純文字傳回你的公用 IP 位址。專為 Shell 腳本、監控和動態 DNS 用戶端設計。

$ curl https://vpnxray.com/ip
216.73.217.51

端點位址

也支援一般的 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。

合理使用