Skip to content

πŸ”„ Multi-platform Dynamic DNS updater for Cloudflare | Supports Windows (PowerShell) and Linux (Python/systemd) | Auto-updates DNS records when your IP changes

License

Notifications You must be signed in to change notification settings

aollivierre/cloudflare-ddns-updater

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Cloudflare DDNS Updater

A robust Dynamic DNS (DDNS) updater for Cloudflare that automatically updates your DNS records when your public IP address changes. Available in both Windows (PowerShell) and Linux (Python) implementations.

🌟 Features

  • Automatic IP Detection: Monitors your public IP and updates DNS records when it changes
  • Multi-Platform Support: Native implementations for both Windows and Linux
  • Reliable Updates: Multiple IP detection services with automatic fallback
  • Secure: Encrypted credential storage and minimal permission requirements
  • 24/7 Operation: Runs continuously as a background service
  • Comprehensive Logging: Detailed logs for troubleshooting and monitoring
  • Easy Configuration: Simple JSON-based configuration

πŸš€ Quick Start

Windows (PowerShell)

# Run with administrator privileges
.\Update-CloudflareDDNS.ps1

# Install as scheduled task
.\Update-CloudflareDDNS.ps1 -InstallTask

Linux (Python)

# Install and start service
sudo ./install.sh

# Check status
systemctl status cloudflare-ddns

πŸ“‹ Requirements

Common Requirements

  • Cloudflare account with a domain
  • API token with DNS edit permissions
  • Internet connection

Windows Specific

  • Windows 10/11 or Windows Server 2016+
  • PowerShell 5.1 or newer
  • Administrator privileges

Linux Specific

  • Linux with systemd (Ubuntu, Debian, CentOS, etc.)
  • Python 3.6+
  • sudo access

πŸ› οΈ Installation

Windows Installation

  1. Download the PowerShell scripts to a permanent location
  2. Run PowerShell as Administrator
  3. Navigate to the script directory
  4. Run: .\Update-CloudflareDDNS.ps1
  5. Follow the interactive menu to configure and install

Linux Installation

  1. Clone the repository or download the files
  2. Edit linux-config/config.json with your details
  3. Run: sudo ./install.sh
  4. Service starts automatically

βš™οΈ Configuration

Cloudflare API Token

  1. Log in to Cloudflare Dashboard
  2. Go to My Profile β†’ API Tokens
  3. Click "Create Token"
  4. Use "Edit zone DNS" template with:
    • Permissions: Zone:DNS:Edit, Zone:Zone:Read
    • Zone Resources: Your specific domain

Configuration File

{
    "Domain": "yourdomain.com",
    "Hostname": "subdomain",
    "ApiToken": "YOUR_API_TOKEN",
    "ZoneId": "YOUR_ZONE_ID",
    "TTL": 120,
    "Proxied": false
}

🌳 Branches

  • main: Windows PowerShell implementation
  • linux-native: Linux Python implementation

πŸ“ Project Structure

cloudflare-ddns/
β”œβ”€β”€ Windows (main branch)
β”‚   β”œβ”€β”€ Update-CloudflareDDNS.ps1
β”‚   β”œβ”€β”€ DDNS/
β”‚   β”‚   └── CloudflareDDNS/
β”‚   β”‚       β”œβ”€β”€ CloudflareDDNS.psd1
β”‚   β”‚       β”œβ”€β”€ CloudflareDDNS.psm1
β”‚   β”‚       β”œβ”€β”€ Public/
β”‚   β”‚       └── Private/
β”‚   └── config/
β”‚
└── Linux (linux-native branch)
    β”œβ”€β”€ cloudflare_ddns.py
    β”œβ”€β”€ cloudflare-ddns.service
    β”œβ”€β”€ install.sh
    β”œβ”€β”€ uninstall.sh
    └── linux-config/

πŸ”§ Usage

Windows Commands

# Interactive menu
.\Update-CloudflareDDNS.ps1

# Silent update
.\Update-CloudflareDDNS.ps1 -Silent

# View logs
.\Update-CloudflareDDNS.ps1 -ShowLog

Linux Commands

# Service management
systemctl start cloudflare-ddns
systemctl stop cloudflare-ddns
systemctl restart cloudflare-ddns
systemctl status cloudflare-ddns

# View logs
journalctl -u cloudflare-ddns -f

# Manual test
python3 cloudflare_ddns.py --config /etc/cloudflare-ddns/config.json --once

πŸ“Š Monitoring

Windows

  • Logs: C:\ProgramData\CloudflareDDNS\*.log
  • Task Scheduler for status

Linux

  • Logs: /var/log/cloudflare-ddns/cloudflare-ddns.log
  • systemd journal: journalctl -u cloudflare-ddns

πŸ› Troubleshooting

Common Issues

  1. Authentication Errors

    • Verify API token is valid
    • Check token permissions
    • Ensure Zone ID is correct
  2. IP Detection Failures

    • Check internet connectivity
    • Verify firewall allows HTTPS outbound
    • Try different IP detection services
  3. Service Won't Start

    • Check logs for specific errors
    • Verify configuration file syntax
    • Ensure proper permissions

🀝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Cloudflare for their excellent API
  • Community contributors and testers
  • IP detection services (ipify, ifconfig.me, etc.)

πŸ“ž Support

πŸ”— Links


Made with ❀️ for the self-hosting community

About

πŸ”„ Multi-platform Dynamic DNS updater for Cloudflare | Supports Windows (PowerShell) and Linux (Python/systemd) | Auto-updates DNS records when your IP changes

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published