Skip to content

A simple Python app to update a DNS record in CloudFlare with the public IPv4 address of the host machine it's running on.

Notifications You must be signed in to change notification settings

sigmaenigma/cloudflare-dns-updater

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

93 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CloudFlare DNS Updater

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.

Prerequisites

Configuration (config.json)

  1. "token": Get your API token from CloudFlare and ensure it has edit permissions.
  2. "zone_name": Get the Zone ID for the domain (a 32-digit alphanumeric string).
  3. "record_name": Add the full subdomain (e.g., test.example.com).
  4. "force_update": Set to true to bypass the IP comparison check.
  5. "interval_minutes": Set the interval for how often to connect to the CloudFlare API (e.g., 15 for every 15 minutes).
  6. 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
}

Installation (Docker)

  1. Clone the repository:
    git clone https://github.com/sigmaenigma/cloudflare-dns-updater.git
  2. Modify the config.json file following the Configuration instructions above.
  3. Build and start the Docker container:
    docker-compose up -d

Installation (Python Standalone)

  1. Clone the repository:
    git clone https://github.com/sigmaenigma/cloudflare-dns-updater.git
  2. Install the requests package:
    pip install requests
  3. Modify the config.json file following the Configuration instructions above.

Running on a Timed Interval (Perpetual)

python3 app.py

Running Manually (Exits on Completion)

python3 app_manual.py

About

A simple Python app to update a DNS record in CloudFlare with the public IPv4 address of the host machine it's running on.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages