来吧兄弟,一起玩一起讨论!
您需要 登录 才可以下载或查看,没有账号?注册
×
分享一个自己写的脚本吧,根据dnspod开发平台写的脚本实现ddns- USERID=""
- TOKEN=""
- DOMAIN=""
- SUBDOMAIN=""
- DOMAIN_ID=""
- RECORD_LIST=""
- i=0;
- current_ip=$(nc ns1.dnspod.net 6666)
- dnspod_domain_get_id(){
- options="login_token=${USERID},${TOKEN}";
- out=$(curl -s -k https://dnsapi.cn/Domain.List -d ${options});
- for line in $out;do
- if [ $(echo $line|grep '<id>' |wc -l) != 0 ];then
- DOMAIN_ID=${line%<*};
- DOMAIN_ID=${DOMAIN_ID#*>};
- #echo "domain id: $DOMAIN_ID";
- fi
- if [ $(echo $line|grep '<name>' |wc -l) != 0 ];then
- DOMAIN_NAME=${line%<*};
- DOMAIN_NAME=${DOMAIN_NAME#*>};
- #echo "domain name: $DOMAIN_NAME";
- if [ "$DOMAIN_NAME" = "$DOMAIN" ];then
- break;
- fi
- fi
- done
- out=$(curl -s -k https://dnsapi.cn/Record.List -d "${options}&domain_id=${DOMAIN_ID}")
- for line in $out;do
- if [ $(echo $line|grep '<id>' |wc -l) != 0 ];then
- RECORD_ID=${line%<*};
- RECORD_ID=${RECORD_ID#*>};
- #echo "record id: $RECORD_ID";
- fi
- if [ $(echo $line|grep '<name>' |wc -l) != 0 ];then
- RECORD_NAME=${line%<*};
- RECORD_NAME=${RECORD_NAME#*>};
- #echo "record name: $RECORD_NAME";
- if [ "$RECORD_NAME" = "$SUBDOMAIN" ];then
- break;
- fi
- fi
- done
- echo "$RECORD_NAME:$RECORD_ID"
- }
- dnspod_update_record_ip(){
- curl -k https://dnsapi.cn/Record.Ddns -d "login_token=${USERID},${TOKEN}&domain_id=${DOMAIN_ID}&record_id=${RECORD_ID}&sub_domain=${RECORD_NAME}&record_line=默认"
- }
- main(){
- dnspod_domain_get_id
- dnspod_update_record_ip
- }
- main
复制代码
|