Python script to update DNS records managed by Gandi. Useful for home servers with dynamic IP addresses.
Uses the ipify API to get the public IPv4 and IPv6 addresses of the server running the script. Each specified record in a specified domain is then updated, if, and only if, the A or AAAA record known by Gandi does not match the corresponding IP address returned by ipify.
Installation is straightforward.
git clone https://gitlab.com/Symplectos/gandi-dynamic-dns.git GandiDynamicDNS
cd GandiDynamicDNS
python3 -m venv env
The script requires the requests library. All requirements can be installed by invoking pip:
source bin/env/activate
pip install -r requirements
To configure the script, a .do.conf file must be created in the root folder of the project:
touch .do.conf
The configuration requires two sections, a Gandi section containing a valid API Access Key, and a DNS section, containing the specific domain and specific records to update. Multiple records can be specified by simply putting each record into a new line:
[Gandi]
key = ***
[DNS]
domain = myDomain.eu
records = sub1
sub2
To automatically run the script periodically, create a cronjob
crontab -e
*/5 * * * * cd /pathToFolder && /pathToFolder/env/bin/python3 /pathToFolder/gandiDynDNS.py
To manually run the script, activate the environment and then invoke the Python interpreter.
source env/bin/activate
python gandiDynDNS.py
The script automatically logs its last run in the gandiDynDNS.log file.
Main Repository on GitLab.
Push Mirrors: