Open tehsunnliu opened 3 years ago
Hey @tehsunnliu . Indeed, I haven't taken IPv6 into account while I was writing this. Let me take a look, and I will get back to this as soon as I have an update.
Hi @sestus, Thank you for your quick response. For now, I've got it working. I've written a script that updates the AAAA record when an IP change is detected.
#!/bin/bash
mydomain="<YOUR_DOMAIN>"
myhostname="<YOUR_SUBDOMAIN_HOST_NAME>"
gdapikey="<YOUR_GODADDY_API_KEY>:<YOUR_GODADDY_API_SECRET>"
logdest="local7.info"
FILE="PreviousIP"
myCurrentIP=$(curl -6 "icanhazip.com")
echo "CurrentIP: ${myCurrentIP}"
myPreviousIP=""
updateIpv6() {
echo "Updating on GoDaddy"
curl -s -X PUT "https://api.godaddy.com/v1/domains/${mydomain}/records/AAAA/${myhostname}" -H "Authorization: sso-key ${gdapikey}" -H "Content-Type: application/json" -d "[{\"data\": \"${myCurrentIP}\"}]"
}
if test -f "$FILE"; then
myPreviousIP=$(cat PreviousIP)
if [ "$myCurrentIP" != "$myPreviousIP" -a "$myPreviousIP" != "" ]; then
updateIpv6
fi
else
#Running for the first time
myPreviousIP=${myCurrentIP}
dnsdata=$(curl -s -X GET -H "Authorization: sso-key ${gdapikey}" "https://api.godaddy.com/v1/domains/${mydomain}/records/AAAA/${myhostname}")
goDaddyIP=$(echo $dnsdata | jq '.[] | .data')
# Remove first and last ""
temp="${goDaddyIP%\"}"
temp="${temp#\"}"
goDaddyIP=$(echo "$temp")
echo "GoDaddyIP: ${goDaddyIP}, MyIP: $myPreviousIP"
if [ "$goDaddyIP" != "$myPreviousIP" -a "$myPreviousIP" != "" ]; then
updateIpv6
fi
# Save IP to file
echo "${myPreviousIP}" >"PreviousIP"
fi
It works only with A record. Is there anyway I can add support for AAAA record?