公告:

openWRT、ddWRT等路由添加dnspod、cloudxns动态域名

作者:star0312 / 时间:7年前 (2018/01/21) / 分类:互联网 / 阅读:3262 / 评论:0

本文转自https://github.com/xdtianyu/scripts/tree/master/ddns,在原作者基础上有所改动。


ddns 更新脚本

这个脚本适用于 openwrt 和 ddwrt 路由动态更新域名。理论上支持所有可以运行 shell (/bin/sh) 脚本的 linux 环境。

使用之前需要打开路由器的webshell,当然也可以使用ssh、telnet等登录到路由器上,也是可以的。

用root账户登陆后默认目录在/root,可以先新建一个目录,在下载脚本。

mkdir ddns


openwrt

1. 下载脚本

cloudxns:

wget https://raw.githubusercontent.com/xdtianyu/scripts/master/ddns/cloudxns.sh
wget https://raw.githubusercontent.com/xdtianyu/scripts/master/ddns/cloudxns.conf
chmod +x cloudxns.sh

dnspod:

wget https://raw.githubusercontent.com/xdtianyu/scripts/master/ddns/dnspod.sh
wget https://raw.githubusercontent.com/xdtianyu/scripts/master/ddns/dnspod.conf
chmod +x dnspod.sh

2. 配置

cloudxns:

API_KEY="YOUR_API_KEY"
SECRET_KEY="YOUR_SECRET_KEY"
DOMAIN="example.com"
HOST="ddns"
LAST_IP_FILE="/tmp/.LAST_IP"

dnspod:

用vi编辑dnspod.conf文件。改成自己的账户和域名。

ACCOUNT="xxxxxx@gmail.com"
PASSWORD="xxxxxxxxxx"
DOMAIN="xxxx.xxx.org"
RECORD_LINE="默认"

3. 运行测试

dnspod: ./dnspod.sh dnspod.conf

cloudxns: ./cloudxns.sh cloudxns.conf

4. 添加到 cron 定时任务

/etc/init.d/cron enable
crontab -e

添加如下内容,注意修改路径

cloudxns:

*/3 * * * * /root/ddns/cloudxns.sh /root/ddns/cloudxns.conf >> /root/ddns/cloudxns.log

dnspod:

进入后按a进入编辑模式,输入下列命令后,按ESC退出编辑模式,输入:wq退出。

*/3 * * * * /root/ddns/dnspod.sh /root/ddns/dnspod.conf >> /root/ddns/dnspod.log

ddwrt

1. 下载脚本

下载脚本及配置文件,保存文件到 /jffs 及 /opt 等不会重启丢失的目录,注意可能需要在网页管理页面先启用 jffs

dnspod:

curl -k -s https://raw.githubusercontent.com/xdtianyu/scripts/master/ddns/dnspod.sh
curl -k -s https://raw.githubusercontent.com/xdtianyu/scripts/master/ddns/dnspod.conf
chmod +x dnspod.sh

cloudxns:

wget https://raw.githubusercontent.com/xdtianyu/scripts/master/ddns/cloudxns.sh
wget https://raw.githubusercontent.com/xdtianyu/scripts/master/ddns/cloudxns.conf
chmod +x cloudxns.sh

2. 修改配置文件

dnspod:

ACCOUNT="xxxxxx@gmail.com"
PASSWORD="xxxxxxxxxx"
DOMAIN="xxxx.xxx.org"
RECORD_LINE="默认"

cloudxns:

API_KEY="YOUR_API_KEY"
SECRET_KEY="YOUR_SECRET_KEY"
DOMAIN="example.com"
HOST="ddns"
LAST_IP_FILE="/tmp/.LAST_IP"

3. 运行测试

dnspod: ./dnspod.sh dnspod.conf

cloudxns: ./cloudxns.sh cloudxns.conf

4. 添加 cron 定时任务

ddwrt 在网页管理页面添加 cron 定时任务,注意修改命令的路径:

dnspod:

*/3 * * * * root /jffs/ddns/dnspod.sh /jffs/ddns/dnspod.conf >> /jffs/ddns/cloudxns.log

cloudxns:

*/3 * * * * root /jffs/ddns/cloudxns.sh /jffs/ddns/cloudxns.conf >> /jffs/ddns/cloudxns.log


  • 我的QQ二维码
  • QQ群
  • 我的微信二维码
  • 微信公众号

没有评论,留下你的印记,证明你来过。


发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。