...
如果DNS服务器不慎被破坏,可将之前定期备份的txt文件拿过来进行恢复
恢复的时候默认创建的是Conditional Primary Zone,如果需要Conditional Forwarder Zone,如果需要Primary Zone可自行在控制台进行转换
恢复脚本res.sh
Code Block |
---|
dnsname=192.168.1.100:5380 username=admin password=Uenpay2023 tokenname=`curl -s "http://$dnsname/api/user/createToken?user=$username&pass=$password&tokenName==zhengyu"|jq .token|sed 's#"##g'` domainlist=( uenpay.com 5ubp.com ) for domains in ${domainlist[@]} do status=`curl -s "http://$dnsname/api/zones/options/get?token=${tokenname}&zone=$domains&includeAvailableTsigKeyNames=true"|jq .status|sed 's#"##g'` if [ $status = "ok" ];then echo "$domains 已存在" else curl "http://$dnsname/api/zones/create?token=${tokenname}&zone=$domains&type=Primary" curl#创建Conditional Forwarder Zone(只能用于单点dns服务) #curl "http://$dnsname/api/zones/create?token=${tokenname}&zone=$domains&type=Forwarder&forwarder=223.5.5.5" fi ##添加A记录 cat ${domains}-*.txt|awk '$2 == "A" { print }'|while read line; do domain=`echo $line|awk '{print $1}'` ip=`echo $line|awk '{print $3}'` curl -s "http://$dnsname/api/zones/records/add?token=$tokenname&domain=$domain.$domains&zone=$domains&type=A&ttl=600&overwrite=true&ipAddress=$ip" done ##添加CNAME记录 cat ${domains}-*.txt|awk '$2 == "CNAME" { print }'|while read line; do domain=`echo $line|awk '{print $1}'` cname=`echo $line|awk '{print $3}'` curl -s "http://$dnsname/api/zones/records/add?token=$tokenname&domain=$domain.$domains&zone=$domains&type=CNAME&ttl=600&overwrite=true&cname=$cname" done done |
...