Loading... ## 安装DDNS 1. 安装pip: ``` apt install python-pip ``` 2. 安装ddns: ``` pip install ddns ``` ## 配置DDNS 1. 编辑配置文件: ``` vim config.json ``` ``` { "$schema": "https://ddns.newfuture.cc/schema/v2.8.json", "debug": false, "dns": "cloudflare", "id": "", "index4": "public", "index6": "default", "ipv4": ["xx.xx.com"], "ipv6": [], "proxy": null, "token": "*", "ttl": null } ``` > 此配置仅获取并更新IPv4地址 > > ipv4:将“xx.xx.com”更改为自己的域名 > > token:填写自己的CF API Token([如何申请?](https://support.cloudflare.com/hc/zh-cn/articles/200167836-%E7%AE%A1%E7%90%86-API-%E4%BB%A4%E7%89%8C%E5%92%8C%E5%AF%86%E9%92%A5))(参照下图设置cf api token) > > ![](https://fuju.life/usr/uploads/2020/11/3584257375.png) 2. 运行DDNS: ``` ddns ``` 出现以下输出即为成功:(如果没有输出即ip没有改变) ``` xx.xx.com(A) ==> xx.xx.xx.xx [via DIRECT] ``` ## 设置定时任务(自动更新) 1. 下载项目: ``` git clone https://github.com/NewFuture/DDNS.git cd DDNS ``` 2. 复制配置文件的`config.json`到DDNS目录下: ``` cp /root/config.json /root/DDNS/config.json ``` 3. 运行脚本(自动配置定时任务): ``` bash task.sh ``` 4. 查看日志:(出现`xx.xx.com(A) ==> xx.xx.xx.xx [via DIRECT]` 即修改dns成功) ``` cat run.log ``` 完成! ## 参考链接 [https://github.com/NewFuture/DDNS](https://github.com/NewFuture/DDNS) Last modification:November 24, 2020 © Allow specification reprint Like