ipv6 script is now working

This commit is contained in:
Roger Sikorski 2022-08-01 22:20:47 +02:00
parent 4f24fad154
commit 589f67b8c1

View File

@ -13,7 +13,7 @@
#Update the first 4 variables with your information #Update the first 4 variables with your information
domain="" # your domain domain="" # your domain
name="" # name of A record to update name="" # name of AAAA record to update
key="" # key for godaddy developer API key="" # key for godaddy developer API
secret="" # secret for godaddy developer API secret="" # secret for godaddy developer API
@ -24,7 +24,7 @@ headers="Authorization: sso-key $key:$secret"
result=$(curl -s -X GET -H "$headers" \ result=$(curl -s -X GET -H "$headers" \
"https://api.godaddy.com/v1/domains/$domain/records/AAAA/$name") "https://api.godaddy.com/v1/domains/$domain/records/AAAA/$name")
dnsIp=$(echo $result | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b") dnsIp=$(echo $result | grep -Eo "2[0-9a-fA-F]{3}:(([0-9a-fA-F]{1,4}[:]{1,2}){1,6}[0-9a-fA-F]{1,4})")
echo "dnsIp:" $dnsIp echo "dnsIp:" $dnsIp
# Get public ip address there are several websites that can do this. # Get public ip address there are several websites that can do this.
@ -33,10 +33,10 @@ echo "currentIp:" $currentIp
if [ $dnsIp != $currentIp ]; if [ $dnsIp != $currentIp ];
then then
# echo "Ips are not equal" # debig # echo "Ips are not equal" # debug
request='{"data":"'$currentIp'","ttl":600}' request='[{"data":"'$currentIp'","name":"'$name'","ttl":600,"type":"AAAA"}]'
# echo $request # debug # echo $request # debug
nresult=$(curl -i -s -X PUT \ result=$(curl -i -s -X PUT \
-H "$headers" \ -H "$headers" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d $request "https://api.godaddy.com/v1/domains/$domain/records/AAAA/$name") -d $request "https://api.godaddy.com/v1/domains/$domain/records/AAAA/$name")