Skip to content

Update IPv4 and IPv6 records on domains managed by Gandi.net

License

Notifications You must be signed in to change notification settings

tkintscher/Gandi-DNS-Updater

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This script updates the A or AAAA records of a subdomain managed by Gandi.

It has no external requirements besides Python 3. This facilitates deployment on lightweight systems such as NAS, Raspberry Pi, etc. and running via schedulers (e.g. systemd-timers or cron).

The external IP address can be determined automatically through the service provided by ifconfig.co. Please respect its rate limit policy:

Please limit automated requests to 1 request per minute. No guarantee is made for requests that exceed this limit. They may be rate-limited, with a 429 status code, or dropped entirely.

Requirements

  • Python 3

Usage

usage: gandi.py [-h] GANDI_API_KEY subdomain.domain.tld {A,AAAA} [address]
  • GANDI_API_KEY is the API key that can be obtained from the administration interface for the domain on the Gandi website.
  • Use A to update the IPv4 record, and AAAA to update the IPv6 record.
  • As for the target address to set, there are three options:

Option A: Automatically determine external IP address

$ ./gandi.py GANDI_API_KEY foo.example.com AAAA

This method uses the service of ifconfig.co to determine the external IP address of the current machine. As mentioned before, please be responsible and do not use this service more than once per minute.

Option B: Use a fixed address

$ ./gandi.py GANDI_API_KEY foo.example.com AAAA ::1

Now the AAAA record of foo.example.com will point to ::1.

Option C: Use the address of another host

$ ./gandi.py GANDI_API_KEY foo.example.com AAAA foobox

The IP address of foobox will be resolved and written to the AAAA record of foo.example.com.

This way one machine can update the records of several other hosts, e.g. on the local network. Note that this may not make much sense if foobox is resolved to a local (IPv4) address as is the case behind NAT.

Use with systemd timers

Regular updates of the domain records can be performed using systemd timers:

  • Edit gandi-update.sh to your needs.
  • In gandi-update.service change the path in ExecStart to the checkout directory.
  • Link the files to systemd's config:
    mkdir -p $HOME/.config/systemd/user
    ln -s $PWD/gandi-update.{service,timer} $HOME/.config/systemd/user
  • Enable the timer:
    systemctl --user enable gandi-update.timer
  • Verify that it worked:
    systemctl --user list-timers

Use with systemd at bootup

An update of the domain records can be done at boot time as follows:

  • Edit gandi-update.sh to your needs.
  • In gandi-update.service change the path in ExecStart to the checkout directory.
  • Link the file to systemd's config:
    mkdir -p $HOME/.config/systemd/user
    ln -s $PWD/gandi-update.service $HOME/.config/systemd/user
  • Enable the service:
    systemctl --user enable gandi-update.service
  • In order to run the script at boot (and not wait for the user to log in), enable a lingering systemd user instance:
    loginctl enable-linger $USER

About

Update IPv4 and IPv6 records on domains managed by Gandi.net

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published