using gandi livedns as a Dynamic DNS server

To experiment with widely distributed systems, I administrate some rasberry pi zeros W scattered in France in residential homes. These systems are attached to residential gateways through Wifi with dynamic IP addresses and I needed a way to reliably connect to them to launch experiments.

In the nineties, I used a service called Dyndns, which offered a free service for updating subdomains with dynamic IPs. This free service no longer exists, so I started looking for an alternatives. Most of them were costly and required the installation of closed-sources update clients. Opensource alternatives such as required complicated installations and also a dedicated domain name.

Hopefully, I've been a loyal customer of Gandi for some years now, and thanks to the introduction their livedns API, it can be used to update my main dns zone through a REST API.

prerequisites: curl jq (apt-get install curl jq)

# retreive current external IP address from Akamai server
MY_IP=$(curl -s  

# Gandi livedn API KEY

# Static Domain hosted at Gandi

# Dynamic Subdomain

#Get the current Zone for the provided domain
CURRENT_ZONE_HREF=$(curl -s -H "X-Api-Key: $APIKEY"$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\"]}" \

I installed this script in a crontab job triggered every 20 min ( same as the rrset_ttl  parameter ) and can access to my PIs whereever I like!