Skip to content

🏷️ Keep a Gandi DNS A record updated with your computer's public IP address

License

Notifications You must be signed in to change notification settings

Aldaviva/GandiDynamicDns

Repository files navigation

Gandi GandiDynamicDns

GitHub Actions Testspace Coveralls

Automatically update a DNS A record in Gandi LiveDNS whenever your computer's public IP address changes, detected automatically using a large, auto-updating pool of public STUN servers.

This is an alternative to filling out monthly CAPTCHAs for No-IP or paying for DynDNS, if you happen to already be paying for a domain name from the world's greatest domain registrar.

Prerequisites

  • .NET 8 Runtime or later
  • Gandi domain name
    • ✅ Domain must be using LiveDNS, the default for new domains (ns-*-*.gandi.net)
    • ❌ Classic DNS (*.dns.gandi.net) is incompatible; you will need to migrate to LiveDNS
    • ❌ External nameservers (with glue records) are incompatible; you will need to update the record on the external nameserver instead of on Gandi's nameservers
  • Your computer must have a public WAN IPv4 address
    • IPv6 is not supported because router NATs don't support IPv6 port forwarding, so an AAAA record wouldn't be useful

Installation

  1. Download the latest release ZIP archive for your operating system and CPU architecture
  2. Extract the ZIP archive to a directory, such as C:\Program Files\GandiDynamicDns\ or /opt/gandidynamicdns/
    • Extract appsettings.json during a new installation, but not when upgrading an existing installation
  3. Install the service
    • Windows: & '.\Install service.ps1'
    • Linux with systemd:
      sudo cp gandidynamicdns.service /etc/systemd/system/
      sudo systemctl daemon-reload
      sudo systemctl enable gandidynamicdns.service

Configuration

Open appsettings.json in a text editor and fill in the following values. Keys marked with ✴ are the most important ones to configure.

Key Type Examples Description
gandiApiKey string abcdefg Generate an API key under Developer access in your Gandi Account. Personal Access Tokens are unfortunately not supported by G6.GandiLiveDns.
domain string example.com
example.co.uk
The second-level domain name that you registered, including the TLD.
subdomain string www
@
api.stage
The subdomain whose DNS record you want to update, not including domain or a trailing period. To update domain itself, set this to @ (default). Can also be a multi-level subdomain.
updateInterval TimeSpan 0.00:05:00 How frequently this program will check if your public IP address has changed and update DNS. Format is d.hh:mm:ss. Defaults to 5 minutes.
One-shot mode: if set to 0:0:0 or negative, this program will exit after the first update attempt, instead of remaining running and updating periodically; useful if you want to trigger it yourself, like with cron.
dnsRecordTimeToLive TimeSpan 0.00:05:00 How long DNS resolvers can cache your record before they must look it up again. Gandi requires this to be between 5 minutes and 30 days, inclusive. Defaults to 5 minutes.
dryRun bool false
true
Set to false (default) to run normally, or true to avoid changing any DNS records.
stunServerBlacklist string[] ["stun.bergophor.de", "stun.usfamily.net"] List of STUN server hostnames to not use when determining your computer's public IP address. Defaults to blocking stun.bergophor.de and stun.usfamily.net due to incorrect responses.

Execution

  • Manually: ./GandiDynamicDns
  • Windows service: sc start GandiDynamicDns, or use services.msc
  • Linux systemd service: sudo systemctl start gandidynamicdns