Instantly share code, notes, and snippets.

Embed
What would you like to do?
Gandl livedns as a DynDNS Server
# retreive current external IP address from Akamai server
MY_IP=$(curl -s http://whatismyip.akamai.com/)
# Gandi livedn API KEY
APIKEY="................."
# Static Domain hosted at Gandi
DOMAIN="nextnet.top"
# Dynamic Subdomain
SUBDOMAIN="pi3gre"
#Get the current Zone for the provided domain
CURRENT_ZONE_HREF=$(curl -s -H "X-Api-Key: $APIKEY" https://dns.api.gandi.net/api/v5/domains/$DOMAIN | jq -r '.zone_records_href')
# Update the A reccord of the Dynamic Subdomain by PUTing on the current zone
curl -D- -X PUT -H "Content-Type: application/json" \
-H "X-Api-Key: $APIKEY" \
-d "{\"rrset_name\": \"$SUBDOMAIN\",
\"rrset_type\": \"A\",
\"rrset_ttl\": 1200,
\"rrset_values\": [\"$MY_IP\"]}" \
$CURRENT_ZONE_HREF/$SUBDOMAIN/A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment