This repository allows the user to update A records on Cloudflare to current IP of the server, commonly called Dynamic DNS.
- Review Cloudflare's help center on creating an API token
- Create a token with Zone:Zone:Read and Zone:DNS:Edit
- Copy .env.default to .env and replace INSERT_TOKEN_HERE with your token.
- Copy .env.default to .env
- Set the ennvironment variables according to your preference (see definitions below)
The repo includes a docker-compose.yml file that you can use to spin everything up. It also supports the CRON_SCHEDULE environment variable to run the script routinely.
docker compose up --build -d
- Create a Python virtual environment:
python -m venv venv
- Open the venv:
source venv/bin/activate
- Install requirements:
pip install -r requirements.txt
- Run the script:
python update.py
CRON_SCHEDULE won't do anything with this method, but you can create your own crontab entry.
CLOUDFLARE_API_TOKEN
: the token you create in Cloudflare. Make sure the token is set up with Zone:Zone:Read and Zone:DNS:EditCLOUDFLARE_FQDNS
: the list of FQDNs you want to updateCRON_SCHEDULE
: the cron schedule for running the script inside the containerRUN_AT_STARTUP
: when starting the container, set to "true" if you want to immediately run the script once. Otherwise set tofalse
FORCE_UPDATE
: force updating the A records, even if they have the current IP addressDRY_RUN
: set to "true" if you want to set the output the script without any changes being applied