支持多种平台的动态域名更新方案
PowerShell 是 Windows 10/11 自带的强大命令行工具。
# 更新所有域名IP
$cred = ConvertTo-SecureString "您的密码" -AsPlainText -Force
$pair = "您的用户名:$cred"
$bytes = [System.Text.Encoding]::ASCII.GetBytes($pair)
$base64 = [System.Convert]::ToBase64String($bytes)
$headers = @{Authorization="Basic $base64"}
Invoke-RestMethod -Uri "https://ddns.yinze.run/nic/update?hostname=您的完整域名" -Method Get -Headers $headers
# 或者一行命令
curl -u "用户名:密码" "https://ddns.yinze.run/nic/update?hostname=您的完整域名"
curl -u "用户名:密码" "https://ddns.yinze.run/nic/update?hostname=您的完整域名"
cmd.exe/c curl -u "用户名:密码" "https://ddns.yinze.run/nic/update?hostname=您的完整域名"# 安装 cron
sudo apt install cron # Debian/Ubuntu
sudo yum install crontabs # CentOS/RHEL
# 添加定时任务,每5分钟更新一次
echo "*/5 * * * * curl -u '用户名:密码' 'https://ddns.yinze.run/nic/update?hostname=您的完整域名' >> /var/log/ddns.log 2>&1" | sudo tee -a /var/spool/cron/crontabs/root
# 启动 cron 服务
sudo service cron start
# 创建 systemd 服务文件
sudo nano /etc/systemd/system/ddns.service
# 文件内容:
[Unit]
Description=RunDDNS Service
After=network-online.target
Wants=network-online.target
[Service]
Type=oneshot
ExecStart=/usr/bin/curl -u '用户名:密码' 'https://ddns.yinze.run/nic/update?hostname=您的完整域名'
PrivateTmp=true
[Install]
WantedBy=multi-user.target
# 创建定时器
sudo nano /etc/systemd/system/ddns.timer
# 文件内容:
[Unit]
Description=RunDDNS Timer
Requires=ddns.service
[Timer]
OnBootSec=1min
OnUnitActiveSec=5min
Unit=ddns.service
[Install]
WantedBy=timers.target
# 启用定时器
sudo systemctl daemon-reload
sudo systemctl enable --now ddns.timer
#!/bin/bash
# 保存为 ddns.sh 并添加执行权限: chmod +x ddns.sh
USERNAME="您的用户名"
PASSWORD="您的密码"
DOMAIN="您的完整域名"
UPDATE_URL="https://ddns.yinze.run/nic/update"
curl -u "$USERNAME:$PASSWORD" "$UPDATE_URL?hostname=$DOMAIN"
# 创建 plist 文件
mkdir -p ~/Library/LaunchAgents
nano ~/Library/LaunchAgents/com.runddns.updater.plist
# 文件内容:
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.runddns.updater</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/curl</string>
<string>-u</string>
<string>用户名:密码</string>
<string>https://ddns.yinze.run/nic/update?hostname=您的完整域名</string>
</array>
<key>StartInterval</key>
<integer>300</integer>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
# 加载任务
launchctl load ~/Library/LaunchAgents/com.runddns.updater.plist
# 编辑 crontab
crontab -e
# 添加行(每5分钟更新):
*/5 * * * * /usr/bin/curl -u "用户名:密码" "https://ddns.yinze.run/nic/update?hostname=您的完整域名"
brew install curl
# 然后使用上述 crontab 方式
# SSH 登录路由器后执行
# 创建更新脚本
cat > /root/ddns_update.sh << 'EOF'
#!/bin/sh
curl -u "用户名:密码" "https://ddns.yinze.run/nic/update?hostname=您的完整域名"
EOF
chmod +x /root/ddns_update.sh
# 添加到 crontab
echo "*/5 * * * * /root/ddns_update.sh" >> /etc/crontabs/root
/etc/init.d/cron enable
/etc/init.d/cron start
https://ddns.yinze.run/nic/update?hostname=<domain>&myip=<ipaddr># 创建事件触发脚本
cat > /etc/hotplug.d iface/95-ddns << 'EOF'
[ "$ACTION" = ifup" ] && [ "$INTERFACE" = wan" ] && {
sleep 5
/root/ddns_update.sh
}
EOF
curl -u "用户名:密码" "https://ddns.yinze.run/nic/update?hostname=您的完整域名"
# 连接 SSH 后
sudo -i # 切换到 root
# 创建脚本
cat > /tmp/ddns.sh << 'EOF'
#!/bin/sh
curl -u "用户名:密码" "https://ddns.yinze.run/nic/update?hostname=您的完整域名"
EOF
chmod +x /tmp/ddns.sh
# 添加到 crontab
echo "*/5 * * * * /tmp/ddns.sh" >> /etc/config/crontab
crontab /etc/config/crontab
# 重启 crond
/etc/init.d/cron restart
# 在 Container Manager 中搜索 alpine
# 创建容器,运行命令:
while true; do curl -u "用户名:密码" "https://ddns.yinze.run/nic/update?hostname=您的完整域名"; sleep 300; done
*/5 * * * *curl -u "用户名:密码" "https://ddns.yinze.run/nic/update?hostname=您的完整域名"
# SSH 登录后
sudo -i # 获取 root 权限
# 创建脚本
cat > /opt/ddns.sh << 'EOF'
#!/bin/sh
curl -u "用户名:密码" "https://ddns.yinze.run/nic/update?hostname=您的完整域名"
logger -t DDNS "更新结果: $(curl -u '用户名:密码' 'https://ddns.yinze.run/nic/update?hostname=您的完整域名')"
EOF
chmod +x /opt/ddns.sh
# 添加到 crontab
(crontab -l 2>/dev/null; echo "*/5 * * * * /opt/ddns.sh") | crontab -
service crond restart
# 在 fnOS Docker 中部署
docker run -d --name ddns-updater \
--restart=always \
alpine sh -c 'apk add --no-cache curl && while true; do curl -u "用户名:密码" "https://ddns.yinze.run/nic/update?hostname=您的完整域名"; sleep 300; done'
ddns-go 是一个通用的 DDNS 客户端,支持自定义 DDNS 服务商,完全可以配合 RunDDNS 使用。
http://localhost:9876https://ddns.yinze.run/nic/update?hostname=[DOMAIN]&myip=[IP]yourname.1798.cloud)DDNSGoUser 格式为 用户名:密码,或者在 ddns-go 界面填写正确的认证信息。
ddns-go 配置文件位于 ~/.ddns-go/config.yaml,可以手动编辑:
custom:
- name: RunDDNS
id: RunDDNS
domain: "yourname.1798.cloud"
ipv4: true
ipv6: false
netinterface: ""
updateUrl: "https://ddns.yinze.run/nic/update?hostname=[DOMAIN]&myip=[IP]"
requestMethod: "GET"
customData:
user: "您的用户名"
password: "您的密码"
https://ddns.yinze.run/nic/update?hostname=您的完整域名&myip=可选IP
使用 HTTP Basic Auth,用户名为注册手机号,密码为账户密码
| 响应 | 说明 |
|---|---|
good |
更新成功 |
nochg |
IP 未变化,无需更新 |
abuse |
请求过于频繁,被限制 |
notfqdn |
域名格式错误 |
nohost |
域名不存在 |