通过github进行下载:https://github.com/NewFuture/DDNS
步骤
-
去阿里云控制台增加accesskey配置:https://help.aliyun.com/document_detail/28637.html
-
上传文件到服务器
-
修改文件执行权限
$ chmod 777 create-task.sh $ chmod 777 ddns
-
初次运行
$ ./ddns -c config.json ddns.czbiao.com(A) ==> 219.137.66.60 [via DIRECT]
-
执行命令创建定时任务
$ bash create-task.sh [ ok ] Reloading configuration files for periodic command scheduler: cron.
配置
config.json
的配置,ipv4是要设置解析的域名。
{
"$schema": "https://ddns.newfuture.cc/schema/v2.8.json",
"debug": false,
"dns": "alidns",
"id": "阿里云RAM的AccessKey",
"index4": "url:http://ip.sb",
"index6": "default",
"ipv4": [
"要进行解析的完整域名"
],
"ipv6": [],
"proxy": null,
"token": "阿里云RAM的AccessKeySecret",
"ttl": null
}
create-task.sh
#!/usr/bin/env bash
RUN_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )";
CMD="\"$RUN_DIR/ddns\" -c \"$RUN_DIR/config.json\" >> \"$RUN_DIR/run.log\"";
echo "*/5 * * * * root $CMD" > /etc/cron.d/ddns;
/etc/init.d/cron reload;