This Python script updates your CloudFlare DNS record with the IP address of your home network. It detects if the IP address saved in CloudFlare differs from the detected IP address of the host where the script is running and updates CloudFlare with the new IPv4 address for a target DNS record.
By default, the main app app.py
runs on an interval specified in the config.json
file. If you want to run it manually, you can run the app_manual.py
file which exists upon completion.
- Python 3.x (If running manually and not using Docker since the Docker setup uses the Python 3.9-Slim image)
- Docker (for Docker installation) Docker Website
- CloudFlare account with API token CloudFlare Instructions to Create a Token
- "token": Get your API token from CloudFlare and ensure it has edit permissions.
- "zone_name": Get the Zone ID for the domain (a 32-digit alphanumeric string).
- "record_name": Add the full subdomain (e.g.,
test.example.com
). - "force_update": Set to
true
to bypass the IP comparison check. - "interval_minutes": Set the interval for how often to connect to the CloudFlare API (e.g.,
15
for every 15 minutes). - Save the file.
Example config.json
:
{
"token": "your_api_token",
"zone_name": "your_zone_id",
"record_name": "test.example.com",
"force_update": true,
"interval_minutes": 15
}
- Clone the repository:
git clone https://github.com/sigmaenigma/cloudflare-dns-updater.git
- Modify the
config.json
file following the Configuration instructions above. - Build and start the Docker container:
docker-compose up -d
- Clone the repository:
git clone https://github.com/sigmaenigma/cloudflare-dns-updater.git
- Install the
requests
package:pip install requests
- Modify the
config.json
file following the Configuration instructions above.
python3 app.py
python3 app_manual.py