I'm risfeng, a java dev in Shanghai.
risfeng / aliyun-ddns-shell Goto Github PK
View Code? Open in Web Editor NEW阿里云域名解析动态更新IP Shell脚本
License: MIT License
阿里云域名解析动态更新IP Shell脚本
License: MIT License
I'm risfeng, a java dev in Shanghai.
IP:124.229.236.43 和 IP:124.229.236.4。判断显示IP相同。
#############################################################
#############################################################
[Info] 2022-05-17 21:20:01 检测到配置文件,自动加载现有配置信息。可通过菜单选项【恢复出厂设置】重置.
[Info] 2022-05-17 21:20:01 正在尝试检测外网:ping www.baidu.com 1 times......
[Success] 2022-05-17 21:20:01 检测外网成功!
[Info] 2022-05-17 21:20:01 正在获取本机外网ip......
[Info] 2022-05-17 21:20:01 本机外网ip:124.229.236.4
[Info] 2022-05-17 21:20:01 正在获取‘’‘域名隐了’‘’的ip......
[Info] 2022-05-17 21:20:01 域名‘’‘域名隐了’‘’的当前ip:124.229.236.43
[Info] 2022-05-17 21:20:01 当前外网ip:[124.229.236.4]与‘’‘域名隐了’‘’(124.229.236.43)的ip相同.
[Success] 2022-05-17 21:20:01 本地ip与域名解析ip未发生任何变动,无需更改,程序退出.
=========== Tue 17 May 2022 09:40:01 PM CST ===========
aliyun-ddns.sh: line 148: syntax error: bad for loop variable
how can i set the message send only when the ip address change?
我遇到了两个问题
第一个
echo -ne "$2" | openssl dgst -$1 -hmac "$3" -binary | base64
我的小盒子没有base64 也不好装 改成如下
echo -ne "$2" | openssl dgst -$1 -hmac "$3" -binary | openssl base64
第二个
for((i=1;i<=$var_check_online_retry_times;i++)); do
我的shell 环境不支持 这个for语法改成如下
for i in {1..3};do
你好:
这个程序至少稳定运行了一年多,今天突然发现不正常了。
1)我检查了log ,发现我的环境,发现
curl -s http://members.3322.org/dyndns/getip 运行后返回的是404 的html。log如图
2) 我实际用终端运行这句,也是返回404 的html
请帮看下要怎么解决 ? 谢谢!
使用@.一级域名无法解析AAAA ipv6 地址;
返回:解析ipv6地址签名错误:
SignatureDoesNotMatch消息:Specified signature is not matched with our calculation. server string to sign is:GET&%2F&AccessKeyId%3***************%26Action%3DUpdateDomainRecord%26Format%3Djson%26RR%3Dstore%26RecordId%3D20504173030569984%26SignatureMethod%3DHMAC-SHA1%26SignatureNonce%3D91c79ecd-2d40-4aa8-87de-3ee628174274%26SignatureVersion%3D1.0%26TTL%3D600%26Timestamp%3D2020-10-03T05%253A49%253A40Z%26Type%3DAAAA%26Value%3D2408%25***************************%253Afe12%253A3456%26Version%3D2015-01-09(ackey ip 用*代替了)
ubuntu中运行aliyun-ddns.sh -run提示未找到命令
只能通过 .aliyun-ddns.sh 或者 base aliyun-ddns.sh 来执行脚本,然后选择3.仅执行脚本 来更新
这样没法设置定时任务了,有其他方法吗,还是我哪里做的不对?
-e [Info] 2021-11-19 21:06:32 正在获取record_id......
curl: option -n%00Uafv7aR9XXMTJqYavIbDxGcUpdQ%3D%00: is unknown
curl: try 'curl --help' or 'curl --manual' for more information
-e [Warning] 2021-11-19 21:06:32 获取record_id为空,可能没有获取到有效的解析记录(record_id=)
请问该怎么解决
不支持配置多个域名
按照提示进行设置后 在阿里云控制台发现 解析记录中主机记录字段下 自动赋值了 二级域名 我本来是为@的 在配置中也没有发现相关该字段的选项
执行脚本后显示更新成功,但没有更新。 初TXT类型之外,其他的A记录正常更新IP,
(因为TXT并不是IP,而是一个字符串?: AVDsoONpIlEdsMZTMZw4ERqQbAnVBQw-lpurWNaaSsc)
配置文件如下:
var_check_online_url="www.baidu.com"
var_check_online_retry_times=3
var_first_level_domain="quantowin.com"
var_second_level_domain="_acme-challenge"
var_domain_record_type="TXT"
var_domian_ttl="600"
var_access_key_id="XXXXX"
var_access_key_secret="XXXXXX"
var_local_wan_ip="cat /opt/acme/dnstxt"
var_domian_server_ip="curl -s http://119.29.29.29/d?dn="
var_enable_message_push=false
var_push_message_access_token=""
var_push_message_secret=""
执行日志:
[Info] 2023-08-01 14:19:14 检测到配置文件,自动加载现有配置信息。可通过菜单选项【恢复出厂设置】重置.
[Info] 2023-08-01 14:19:14 正在尝试检测外网:ping www.baidu.com 1 times......
[Success] 2023-08-01 14:19:14 检测外网成功!
[Info] 2023-08-01 14:19:14 正在获取本机外网ip......
[Info] 2023-08-01 14:19:14 本机外网ip:AVDsoONpIlEdsMZTMZw4ERqQbAnVBQw-lpurWNaaSsc
[Info] 2023-08-01 14:19:14 正在获取_acme-challenge.quantowin.com的ip......
[Info] 2023-08-01 14:19:14 域名_acme-challenge.quantowin.com的当前ip:
[Info] 2023-08-01 14:19:14 正在更新域名解析记录值......
[Info] 2023-08-01 14:19:14 正在获取record_id......
[Info] 2023-08-01 14:19:14 获取到到record_id=702846738585269248
]...... 2023-08-01 14:19:14 正在更新解析记录:[_acme-challenge.quantowin.com]的ip为[AVDsoONpIlEdsMZTMZw4ERqQbAnVBQw-lpurWNaaSsc
[Success] 2023-08-01 14:19:14 阿里云UpdateDomainRecord接口请求处理成功,返回消息:
[Info] 2023-08-01 14:19:14 已经更新record_id=702846738585269248的记录
)记录更新成功。08-01 14:19:14 域名[_acme-challenge.quantowin.com](新IP:AVDsoONpIlEdsMZTMZw4ERqQbAnVBQw-lpurWNaaSsc
*.text.xx.com
Specified signature is not matched with our calculation. server string to sign is:GET ...xxxx
在这行
aliyun-ddns-shell/src/aliyun/aliyun-ddns.sh
Line 240 in 219ac8e
我自定义获取wan ip的命令后
curl -s http://ip4.ouc.edu.cn/Default2.aspx | grep '访客IP地址: ' | sed 's/:/\n/g' | sed '1d' | sed 's/</\n/g' | sed '2d' | sed '2d' | sed '1,1 s/^.//g'
运行程序只能得到curl的结果,而不是后面的ip地址,结果附在最后
因此我只能手动改掉这一行,目前可以正常使用
var_local_wan_ip=`curl -s http://ip4.ouc.edu.cn/Default2.aspx | grep '访客IP地址: ' | sed 's/:/\n/g' | sed '1d' | sed 's/</\n/g' | sed '2d' | sed '2d' | sed '1,1 s/^.//g'`
#var_local_wan_ip=`${var_local_wan_ip}`
附上curl的结果供参考
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>
</title></head>
<body>
<form method="post" action="./Default2.aspx" id="form1">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="L07yESAT50CeA13U36h4ZrAtKEvwVaTD08lyqE+1H+/MSG9mIdDClItr060ShQ/na1++C44a3iy4Am4h0v9kG4QZDu9nVjl60a8rJkNBv7n0HCMvctexxEtouPdMl9R+Q9IJqq5JM41JYnl8ylzVbdWW2HPY6mndtuAor4t+Qj0=" />
<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="9BD98A7D" />
<div>
<pre id="best-content-2392302861" accuse="aContent" class="best-text mb-10" style="margin: 10px 0px; padding: 0px; font-family: "PingFang SC", "Lantinghei SC", "Microsoft YaHei", arial, 宋体, sans-serif, tahoma; white-space: pre-wrap; word-wrap: break-word; font-size: 16px; line-height: 29px; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial; min-height: 55px;"><span id="Label1">访客IP地址: 10.190.10.125</span></pre>
</div>
</form>
</body>
</html>
原版程序的运行结果
root@***-145VM:~# sh /mnt/sdb1/App/aliddns/aliyun-ddns.sh -run
=========== 2022年 11月 23日 星期三 21:03:59 CST ===========
#############################################################
# Aliyun Domain DNS Update Shell Script
#
# Dynamic DNS Update Using Aliyun API
#
# Version: v1.0.0
# BuildDate: 20200307
# Author: risfeng<[email protected]>
# GitHub: https://github.com/risfeng/aliyun-ddns-shell
#
# Usage: please refer to https://github.com/risfeng/aliyun-ddns-shell/blob/master/README.md
#
#############################################################
[Info] 2022-11-23 21:03:59 检测到配置文件,自动加载现有配置信息。可通过菜单选项【恢复出厂设置】重置.
[Info] 2022-11-23 21:03:59 正在尝试检测外网:ping www.baidu.com 1 times......
[Success] 2022-11-23 21:03:59 检测外网成功!
[Info] 2022-11-23 21:03:59 正在获取本机外网ip......
[Info] 2022-11-23 21:03:59 本机外网ip:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>
</title></head>
<body>
<form method="post" action="./Default2.aspx" id="form1">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="0qnytskylSD8Vy2l2Oa8+l96+6Myq4GX071uGNeVqOJBb1RYCnyLqYcqmqDEBpsb0W1fHltE8CSVKjEZZ7Ruy07S6vsuYBboFn2lbh29t77HgLAOrbAkIqBQbAdvGVBp0zp+u8iX5HXzE7xpf1xYRTolbuzzQ3ZOuNxesJpl5HM=" />
<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="9BD98A7D" />
<div>
<pre id="best-content-2392302861" accuse="aContent" class="best-text mb-10" style="margin: 10px 0px; padding: 0px; font-family: "PingFang SC", "Lantinghei SC", "Microsoft YaHei", arial, 宋体, sans-serif, tahoma; white-space: pre-wrap; word-wrap: break-word; font-size: 16px; line-height: 29px; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial; min-height: 55px;"><span id="Label1">访客IP地址: 10.190.10.125</span></pre>
</div>
</form>
</body>
</html>
[Info] 2022-11-23 21:03:59 正在获取******的ip......
[Info] 2022-11-23 21:03:59 域名******的当前ip:
[Info] 2022-11-23 21:03:59 正在更新域名解析记录值......
[Info] 2022-11-23 21:03:59 正在获取record_id......
[Info] 2022-11-23 21:03:59 获取到到record_id=797644783185760256
[Info] 2022-11-23 21:03:59 正在更新解析记录:[******]的ip为[
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>
</title></head>
<body>
<form method="post" action="./Default2.aspx" id="form1">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="0qnytskylSD8Vy2l2Oa8+l96+6Myq4GX071uGNeVqOJBb1RYCnyLqYcqmqDEBpsb0W1fHltE8CSVKjEZZ7Ruy07S6vsuYBboFn2lbh29t77HgLAOrbAkIqBQbAdvGVBp0zp+u8iX5HXzE7xpf1xYRTolbuzzQ3ZOuNxesJpl5HM=" />
<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="9BD98A7D" />
<div>
<pre id="best-content-2392302861" accuse="aContent" class="best-text mb-10" style="margin: 10px 0px; padding: 0px; font-family: "PingFang SC", "Lantinghei SC", "Microsoft YaHei", arial, 宋体, sans-serif, tahoma; white-space: pre-wrap; word-wrap: break-word; font-size: 16px; line-height: 29px; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial; min-height: 55px;"><span id="Label1">访客IP地址: 10.190.10.125</span></pre>
</div>
</form>
</body>
]......
[Info] 2022-11-23 21:03:59 已经更新record_id=797644783185760256的记录
[Success] 2022-11-23 21:03:59 域名[******](新IP:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>
</title></head>
<body>
<form method="post" action="./Default2.aspx" id="form1">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="0qnytskylSD8Vy2l2Oa8+l96+6Myq4GX071uGNeVqOJBb1RYCnyLqYcqmqDEBpsb0W1fHltE8CSVKjEZZ7Ruy07S6vsuYBboFn2lbh29t77HgLAOrbAkIqBQbAdvGVBp0zp+u8iX5HXzE7xpf1xYRTolbuzzQ3ZOuNxesJpl5HM=" />
<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="9BD98A7D" />
<div>
<pre id="best-content-2392302861" accuse="aContent" class="best-text mb-10" style="margin: 10px 0px; padding: 0px; font-family: "PingFang SC", "Lantinghei SC", "Microsoft YaHei", arial, 宋体, sans-serif, tahoma; white-space: pre-wrap; word-wrap: break-word; font-size: 16px; line-height: 29px; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial; min-height: 55px;"><span id="Label1">访客IP地址: 10.190.10.125</span></pre>
</div>
</form>
</body>
)记录更新成功。
运行指令:
./aliyun-ddns-shell/src/aliyun/aliyun-ddns.sh -config
会在家目录创建名为~
的文件夹。
创建一个之前不存在的二级域名时,获取record_id为空,是否可以调用 API 新建一个记录呢?
/aliyun-ddns.sh:行701: uuidgen:未找到命令
centos8有这个命令
可否优化
[Info] 2021-01-26 11:34:59 正在更新解析记录:[]的ip为[]......
[Warning] 2021-01-26 11:34:59 阿里云UpdateDomainRecord接口请求处理失败,返回代码:SignatureDoesNotMatch消息:Specified signature is not matched with our calculation. server string to sign is:GET&%2F&AccessKeyId%3D**********************%26Action%3DUpdateDomainRecord%26Format%3Djson%26RR%3Draspberry%26RecordId%3D21145253099501568%26SignatureMethod%3DHMAC-SHA1%26SignatureNonce%3D1bd07010-8c1b-47c5-bd99-a244bae57594%26SignatureVersion%3D1.0%26TTL%3D600%26Timestamp%3D2021-01-26T03%253A35%253A05Z%26Type%3DAAAA%26Value%3D2409%253A8a20%253A5e61%253A4919%253Ad5c9%253A4be7%253Aa5ac%253A921f%26Version%3D2015-01-09
[Info] 2021-01-26 11:34:59 已经更新record_id=21145253099501568的记录
脚本里二级域名如果写@的话 会报错。我想直接解析到一级域名的话如何填写呢
这个脚本写道1000行了, 厉害。 两个问题反馈以下:
1:uuid 可以用 cat /proc/sys/kernel/random/uuid 获得,而不需要特别安装 uuidgen
2:如果记录是四个A 的ipv6记录,用 curl 获取的外网地址只能是ipv4,这儿有错,应该用 curl -6 https://ipv6.icanhazip.com
运行后都正常提示而且说,更新成功。
但是查看日志dns值并没有修改更新.
我安装了 bind9-utils
问题不大吧
软件源没有 bind-utils
“debian 10”
运行出现如下错误
获取record_id为空,可能没有获取到有效的解析记录(record_id=)
[Info] 2020-04-16 23:01:24 检测到配置文件,自动加载现有配置信息。可通过菜单选项【恢复出厂设置】重置.
[Info] 2020-04-16 23:01:24 正在尝试检测外网:ping www.baidu.com 1 times......
[Success] 2020-04-16 23:01:24 检测外网成功!
[Info] 2020-04-16 23:01:24 正在获取本机外网ip......
[Info] 2020-04-16 23:01:24 本机外网ip:180.106.51.27
[Info] 2020-04-16 23:01:24 正在获取cloud.wx2share.com的ip......
[Info] 2020-04-16 23:01:24 域名cloud.wx2share.com的当前ip:0.0.0.0
[Info] 2020-04-16 23:01:24 正在更新域名解析记录值......
[Info] 2020-04-16 23:01:24 正在获取record_id......
[Warning] 2020-04-16 23:01:24 获取record_id为空,可能没有获取到有效的解析记录(record_id=)
[Failed] 2020-04-16 23:01:24 域名解析记录更新失败!
[Info] 2020-04-16 23:01:24 正在推送消息到钉钉......
社区软件仓库没 bind-utils
所有apt install bind-utils 应该没用
配置里二级域名使用泛域名“*”的话,执行的时候每次都会失败: “获取record_id为空,可能没有获取到有效的解析记录”。
阿里云后台是加了“*”的主机记录的, 用其他的二级域名没有这个问题
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.