Skip to content

A Python tool for automatically updating Cloudflare DNS records to handle dynamic IPs, supporting multiple domains, zones, and proxy settings.

License

Notifications You must be signed in to change notification settings

alexplesoiu/dns-updater

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DNS Updater

DNS Updater is a Python-based tool that automatically updates Cloudflare DNS records with your public IP address. If your server's IP address changes frequently or you have dynamic ip, this tool ensures that your domains and subdomains always point to the correct server. It can handle multiple domains and subdomains from multiple zones, with proxying enabled or disabled. The tool runs checks and updates every 5 minutes and includes redundancy for IP checking services.

Features

  • Update multiple domains/subdomains from different zones
  • Enable or disable proxying for each domain
  • Redundancy for IP checking services
  • Automatically runs checks and updates every 5 minutes
  • Docker support for easy deployment

Prerequisites

  • Python 3.11
  • Docker (optional)

Installation

Clone the repository:

git clone https://github.com/alexplesoiu/dns-updater.git
cd dns-updater

Install the required Python packages:

pip install -r requirements.txt

Configuration

Edit the update_dns.py script and replace the placeholders for API_KEY, EMAIL, and the DOMAINS_TO_UPDATE list with your actual data.

Example configuration:

API_KEY = 'your_cloudflare_api_key'
EMAIL = 'your_email'
DOMAINS_TO_UPDATE = [
    {
        'zone_id': 'zone_id_1',
        'domain': 'subdomain1.example.com',
        'proxied': True
    },
    {
        'zone_id': 'zone_id_1',
        'domain': 'subdomain2.example.com',
        'proxied': False
    },
    {
        'zone_id': 'zone_id_2',
        'domain': 'subdomain.example.org',
        'proxied': True
    }
]

Usage

Run the script:

python update_dns.py

Docker Deployment

Build the Docker container:

docker build -t dns-updater .

Run the Docker container:

docker run -d --name dns-updater --restart unless-stopped dns-updater

This will run the container in detached mode and ensure it starts automatically when the server restarts, unless you explicitly stop it.

Tutorial

Here is a guide that shows you how to get the API Keys on cloudflare and how to set up this tool.

https://blog.devgenius.io/dns-updater-a-solution-for-managing-dynamic-ips-with-cloudflare-31be2f85d9fb

About

A Python tool for automatically updating Cloudflare DNS records to handle dynamic IPs, supporting multiple domains, zones, and proxy settings.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published