The main script is update_ddns.py
- it can be used either independenty or in a Docker container.
The script uses the Cloudflare Python library and is based on the following example with the slightest changes.
In runs in foreground and attempts to update a given DNS record every six hours.
- Python 3
- Module dependencies
- CloudFlare
- requests
- schedule
Either declare the following variables in your environment:
export [email protected]
export CF_API_KEY=your_cloudflare_api_key
or create a file named .cloudflare.cnf
with the following content in a directory containing the script"
[CloudFlare]
email = [email protected]
token = your_cloudflare_api_key
Optional: record update interval can be set in environment variable SCHED_TIME
, which must be a number of seconds.
If not set or set incorrectly, it defaults to 21600 seconds (6 hours). For simplicity, negative values will be converted to absolute.
Note that setting this value too low may cause the API request limit to be exceeded.
Run the script by issuing the following command: ./update_ddns.py your.domain.name
.
docker run -d -e [email protected] \
-e CF_API_KEY=your_cloudflare_api_key \
zonked/cloudflare_ddns your.domain.name
Or you can mount a configuration file like this:
docker run -d -v $(PWD)/.cloudflare.cnf:/app/.cloudflare.cnf:ro \
zonked/cloudflare_ddns your.domain.name