Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work with IPv6 #6

Open
tehsunnliu opened this issue Apr 10, 2021 · 2 comments
Open

Doesn't work with IPv6 #6

tehsunnliu opened this issue Apr 10, 2021 · 2 comments

Comments

@tehsunnliu
Copy link

It works only with A record. Is there anyway I can add support for AAAA record?

@mikemyl
Copy link
Owner

mikemyl commented Apr 10, 2021

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.

@tehsunnliu
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants