Go to file
2023-08-04 23:10:47 +02:00
dyn_gandi updated nix modules 2023-08-04 23:10:47 +02:00
nix updated nix modules 2023-08-04 23:10:47 +02:00
tests working flake 2023-07-26 22:27:02 +02:00
.envrc added direnv support 2023-08-03 14:22:29 +02:00
.gitignore formatting, minor tweaks, fixed txpo 2023-08-03 23:14:04 +02:00
flake.lock working flake 2023-07-26 22:27:02 +02:00
flake.nix formatting, minor tweaks, fixed txpo 2023-08-03 23:14:04 +02:00
poetry.lock working flake 2023-07-26 22:27:02 +02:00
pyproject.toml working flake 2023-07-26 22:27:02 +02:00
README.md fixed typo 2023-08-01 21:12:03 +02:00

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