Skip to content

Instantly share code, notes, and snippets.

@rajkumaar23
Created December 27, 2023 03:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rajkumaar23/ec05d447c76d5245b3f90d676a12b633 to your computer and use it in GitHub Desktop.
Save rajkumaar23/ec05d447c76d5245b3f90d676a12b633 to your computer and use it in GitHub Desktop.
A script to check and update GoDaddy DNS
#!/bin/bash
# Taken from https://github.com/markafox/GoDaddy_Powershell_DDNS
domain="rajkumaar.co.in" # your domain
name="pi" # name of A record to update
key="" # key for godaddy developer API
secret="" # secret for godaddy developer API
headers="Authorization: sso-key $key:$secret"
result=$(curl -s -X GET -H "$headers" "https://api.godaddy.com/v1/domains/$domain/records/A/$name")
dnsIp=$(echo $result | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b")
ret=$(curl -s GET "http://ipinfo.io/json")
currentIp=$(echo $ret | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b")
if [ "$dnsIp" != "$currentIp" ];
then
request='[{"data":"'$currentIp'","ttl":3600}]'
nresult=$(curl -i -s -X PUT \
-H "$headers" \
-H "Content-Type: application/json" \
-d $request "https://api.godaddy.com/v1/domains/$domain/records/A/$name")
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment