DynDNS Pt.II – Gandi LiveDNS REST API

This is the followup Post to my previous post dynamic-dns-update-domain-record-yourself

My Registrar Gandi.net is updating their website and has also created a new Domain Name Record System which can be accessed by a new API. So the old Post is already outdated if you have switched to the new DNS System with your domain.

So i had to write a new updating script gandi-live-dns to keep my various subdomains at home up to date whenever my ISP thinks the IP needs to be changed.

The API is described here in the Docs and works well enough, regardless the BETA state.

API Key

Start by retrieving your API Key from the “Security” section in new Account admin panel to be able to make authenticated requests to the API.

Then make sure you replace “XXX” with your API Key in all the following examples.

API Curl Example and find your UUID/Zone File ID

The Zone File Logic has been changed to UUID Zone Files. The UUID can be queried with CURL easily.

Info on domain “DOMAIN”

  • GET /domains/<DOMAIN>:

    curl -H 'X-Api-Key: XXX' https://dns.beta.gandi.net/api/v5/domains/<DOMAIN>
    

    return:

    {"zonedata": "/zones/<UUID>/records",
     "fqdn": "<DOMAIN>",
     "zone": "/zones/<UUID>"}
    

New Update Script

The script is named gandi-live-dns and available at GitHub under a GPLv3 License. It’s written in Python and uses requests. Missing subdomains are created if they have not yet been created. If the WAN IP of my home router is different to the IP of my subdomain records, the script updates all provided subdomains with the REST API.

Detailed descriptions and install/usage instructions are available at the README. Feel free to create an issue if there are any questions or create a pull request for updates.

 

Comments are closed.