Go to file
Kristian Krsnik 9fd24c4650 added flake.nix 2023-07-26 00:55:09 +02:00
.gitignore initial commit 2023-07-26 00:49:47 +02:00
README.md initial commit 2023-07-26 00:49:47 +02:00
dyn-gandi.py initial commit 2023-07-26 00:49:47 +02:00
flake.nix added flake.nix 2023-07-26 00:55:09 +02:00

README.md

Dyn-Gandi

A DNS record updater for Gandi's LiveDNS API. This script is heavily inspired by dyn-gandi.

How it works

This script determines the your server's current IP by querying the resolvers defined in the config file. After that it reads the current state of the domains and subdomains you specified of Gandi. Should the IP address of a subdomain not match your current IP it will be updated. The subdomain will be created should it not already exist.

Note

The current implementation only allows for one entry per subdomain. Meaning that should you have a TXT and a CNAME record for a subdomain that is in the config file, then both these entries will be deleted and replaced by a single A name record.

How to use

First, get your API key from https://account.gandi.net/en/users/USER/security where USER is your Gandi username. On first run the program will create a minimal, yet complete config.json in the same directory it is being run in.
Next, enter the API key into the configuration file and assign domains to it. The domains are keys to a list of subdomain for a given domain you wish to monitor. The below example is complete and should explain itself. Resolvers are queried one after another until one returns a valid IP.

config.json

{
  "api": {
    "<Your-API-Key>": {
      "example.com": [ "@", "www", "sub1" ],
      "example.org": [ "@", "www", "sub1", "sub2" ]
    }
  },
  "ttl": 3600,
  "resolvers": [
    "https://ifconfig.me/ip"
    "https://me.gandi.net"
  ],
  "log_path": "./log.txt"
}

Features

  • Support for arbitrarily many domains and records through a nested data structure.
  • Small codebase.
  • Logging

Limitations

  • Right now only IPv4 addresses are supported
  • Every record is only allowed one A record.
  • Extra records (TXT, CNAME and such) will get deleted on update.

TODO

  • Testing
  • Command line options controlling: dry-run, config, log, verbosity, force
  • Per subdomain TTL
  • Nix Flake support with exported config and service options
  • Better documentation
  • Better logging
  • Support IPv6
  • Remember other record types (TXT, etc.)
  • Detect TTL change and update even when the IP is the same