使用dnspod api更新 ddns

益智明
2023-12-01
获取domain id

可以按格式显示

curl https://dnsapi.cn/Domain.List -d "login_token=toker_ID,token&format=json"
{"status":{"code":"1","message":"Action completed successful","created_at":"2018-11-25 22:22:54"},"info":{"domain_total":4,"all_total":4,"mine_total":4,"share_total":"0","vip_total":0,"ismark_total":0,"pause_total":0,"error_total":0,"lock_total":0,"spam_total":0,"vip_expire":0,"share_out_total":0},"domains":[{"id":domain id,"status":"enable","grade":"DP_Free","group_id":"1","searchengine_push":"no","is_mark":"no","ttl":"600","cname_speedup":"disable","remark":"","created_on":"2018-11-25 00:28:40","updated_on":"2018-11-25 00:28:40","punycode":"域名","ext_status":"","src_flag":"QCLOUD","name":"域名","grade_title":"\u65b0\u514d\u8d39\u5957\u9910","is_vip":"no","owner":"用户名","records":"9"},{"id":domain id,"status":"enable","grade":"DP_Free","group_id":"1","searchengine_push":"no","is_mark":"no","ttl":"600","cname_speedup":"disable","remark":"","created_on":"2018-11-25 00:06:58","updated_on":"2018-11-25 00:06:58","punycode":"ccoo.ga","ext_status":"","src_flag":"DNSPOD","name":"ccoo.ga","grade_title":"\u65b0\u514d\u8d39\u5957\u9910","is_vip":"no","owner":"用户名","records":"2"},{"id":domain id,"status":"enable","grade":"DP_Free","group_id":"1","searchengine_push":"no","is_mark":"no","ttl":"600","cname_speedup":"disable","remark":"","created_on":"2018-11-25 00:05:01","updated_on":"2018-11-25 00:05:01","punycode":"mufo.ml","ext_status":"","src_flag":"DNSPOD","name":"mufo.ml","grade_title":"\u65b0\u514d\u8d39\u5957\u9910","is_vip":"no","owner":"用户名","records":"2"},{"id":domain id,"status":"enable","grade":"DP_Free","group_id":"1","searchengine_push":"no","is_mark":"no","ttl":"600","cname_speedup":"disable","remark":"","created_on":"2018-11-23 22:41:43","updated_on":"2018-11-23 22:41:43","punycode":"uedu.ml","ext_status":"","src_flag":"DNSPOD","name":"uedu.ml","grade_title":"\u65b0\u514d\u8d39\u5957\u9910","is_vip":"no","owner":"用户名","reco

也可以更改为其它格式的显示:

https://dnsapi.cn/Domain.List -d "login_token=toker_ID,token&format=yaml"
<?xml version="1.0" encoding="UTF-8"?>
<dnspod>
<status>
<code>1</code>
<message>Action completed successful</message>
<created_at>2018-11-25 22:25:57</created_at>
</status>
<info>
<domain_total>4</domain_total>
<all_total>4</all_total>
<mine_total>4</mine_total>
<share_total>0</share_total>
<vip_total>0</vip_total>
<ismark_total>0</ismark_total>
<pause_total>0</pause_total>
<error_total>0</error_total>
<lock_total>0</lock_total>
<spam_total>0</spam_total>
<vip_expire>0</vip_expire>
<share_out_total>0</share_out_total>
</info>
<domains>
<item>
<id>domain id</id>
<status>enable</status>
<grade>DP_Free</grade>
<group_id>1</group_id>
<searchengine_push>no</searchengine_push>
<is_mark>no</is_mark>
<ttl>600</ttl>
<cname_speedup>disable</cname_speedup>
<remark></remark>
<created_on>2018-11-25 00:28:40</created_on>
<updated_on>2018-11-25 00:28:40</updated_on>
<punycode>域名</punycode>
<ext_status></ext_status>
<src_flag>QCLOUD</src_flag>
<name>域名</name>
<grade_title><![CDATA[新免费套餐]]></grade_title>
<is_vip>no</is_vip>
<owner>用户名</owner>
<records>9</records>
</item>
<item>
<id>domain id</id>
<status>enable</status>
<grade>DP_Free</grade>
<group_id>1</group_id>
<searchengine_push>no</searchengine_push>
<is_mark>no</is_mark>
<ttl>600</ttl>
<cname_speedup>disable</cname_speedup>
<remark></remark>
<created_on>2018-11-25 00:06:58</created_on>
<updated_on>2018-11-25 00:06:58</updated_on>
<punycode>ccoo.ga</punycode>
<ext_status></ext_status>
<src_flag>DNSPOD</src_flag>
<name>域名</name>
<grade_title><![CDATA[新免费套餐]]></grade_title>
<is_vip>no</is_vip>
<owner>用户名</owner>
<records>2</records>
</item>
<item>
<id>domain id</id>
<status>enable</status>
<grade>DP_Free</grade>
<group_id>1</group_id>
<searchengine_push>no</searchengine_push>
<is_mark>no</is_mark>
<ttl>600</ttl>
<cname_speedup>disable</cname_speedup>
<remark></remark>
<created_on>2018-11-25 00:05:01</created_on>
<updated_on>2018-11-25 00:05:01</updated_on>
<punycode>mufo.ml</punycode>
<ext_status></ext_status>
<src_flag>DNSPOD</src_flag>
<name>域名</name>
<grade_title><![CDATA[新免费套餐]]></grade_title>
<is_vip>no</is_vip>
<owner>用户名</owner>
<records>2</records>
</item>
<item>
<id>domain id</id>
<status>enable</status>
<grade>DP_Free</grade>
<group_id>1</group_id>
<searchengine_push>no</searchengine_push>
<is_mark>no</is_mark>
<ttl>600</ttl>
<cname_speedup>disable</cname_speedup>
<remark></remark>
<created_on>2018-11-23 22:41:43</created_on>
<updated_on>2018-11-23 22:41:43</updated_on>
<punycode>uedu.ml</punycode>
<ext_status></ext_status>
<src_flag>DNSPOD</src_flag>
<name>域名</name>
<grade_title><![CDATA[新免费套餐]]></grade_title>
<is_vip>no</is_vip>
<owner>用户名</owner>
<records>6</records>
</item>
</domains>
</dnspod>
获取record line id
curl -X POST https://dnsapi.cn/Record.List -d 'login_token=toker_ID,token&format=json&domain_id=domain id&sub_domain=r&record_type=A&offset=0&length=3'
{"status":{"code":"1","message":"Action completed successful","created_at":"2018-11-25 22:36:22"},"domain":{"id":domain id,"name":"域名","punycode":"域名","grade":"DP_Free","owner":"用户名","ext_status":"","ttl":600,"min_ttl":600,"dnspod_ns":["f1g1ns1.dnspod.net","f1g1ns2.dnspod.net"],"status":"enable"},"info":{"sub_domains":"9","record_total":"1","records_num":"1"},"records":[{"id":"record id","ttl":"600","value":"IP","enabled":"1","status":"enabled","updated_on":"2018-11-25 15:40:22","name":"主机名或者子域名","line":"\u9ed8\u8ba4","line_id":"0","type":"A","weight":null,"monitor_status":"","remark":"","use_aqb":"no","mx":"0"}]}
更新动态ddns
curl -X POST https://dnsapi.cn/Record.Ddns -d 'login_token=toker_ID,token&format=json&domain_id=domain id&record_id=393227622&record_line_id=0&sub_domain=r'

梅林固件添加自动更新脚本:

vi /jffs/scripts/ddns-start
#!/bin/sh
curl -X POST https://dnsapi.cn/Record.Ddns -d 'login_token=toker_ID,token&format=json&domain_id=domain id&record_id=record_id&record_line_id=0&sub_domain=r'
if [ $? -eq 0 ]; then
  /sbin/ddns_custom_updated 1
else
  /sbin/ddns_custom_updated 0
fi
chmod +x /jffs/scripts/ddns-start

官方API文档:
http://www.dnspod.cn/docs/records.html#dns

转载于:https://blog.51cto.com/m51cto/2321874

 类似资料: