A Bash-based script to automatically update Cloudflare DNS records with your dynamic public IP address. Designed for efficiency and compatibility across Linux and macOS, and on Windows through Git Bash, MSYS2 or WSL.
📖 Full documentation (English & Español): jmrplens.github.io/Cloudflare-DNS-Updater
- Batch Updates: Updates multiple DNS records in a single API call to minimize latency.
- IP Detection:
- Local: Detects global IPv6 addresses directly from the network interface.
- External: Uses multiple fallback services (
icanhazip,ifconfig.co,ipify) for redundancy.
- Cross-Platform: Standalone binaries for Linux and macOS; on Windows, run from source under Git Bash, MSYS2 or WSL.
- Notifications: Support for Telegram and Discord alerts upon IP changes.
- Logging: Rotation-aware logs with optional debug mode.
- Safety: Lockfile mechanism to prevent concurrent executions.
Pre-compiled binaries bundle Bash and jq, so neither has to be installed on the host. curl and the usual command line tools (tar, sed, grep) are taken from the system.
- Download the latest release for your OS from the Releases Page.
- Linux:
cf-updater-linux-x86_64(Intel/AMD) orcf-updater-linux-aarch64(ARM/Raspberry Pi) - macOS:
cf-updater-macos-x86_64(Intel) orcf-updater-macos-aarch64(Apple Silicon)
- Linux:
- Make Executable (Linux/macOS only):
chmod +x cf-updater-linux-x86_64
If you prefer to run the script directly, ensure you have the required dependencies installed.
Dependencies:
Setup:
- Clone the repository:
git clone https://github.com/jmrplens/Cloudflare-DNS-Updater.git cd Cloudflare-DNS-Updater - Run the script:
./cloudflare-dns-updater.sh
Copy the example configuration file and edit it with your details.
cp config.example.yaml cloudflare-dns.yaml
chmod 600 cloudflare-dns.yaml # it contains your API tokenExample cloudflare-dns.yaml:
---
cloudflare:
zone_id: "your_zone_id_here"
api_token: "your_api_token_here"
options:
proxied: true # Default for all domains: true = Orange Cloud (Proxy), false = DNS only
ttl: 1 # Default TTL: 1 = Auto, or value in seconds (60-86400)
interface: "" # Optional: network interface for local IPv6 detection (e.g., "eth0")
domains:
# Update both IPv4 and IPv6 (default)
- name: "example.com"
# Update only IPv4
- name: "ipv4.example.com"
ip_type: "ipv4"
# Update only IPv6
- name: "ipv6.example.com"
ip_type: "ipv6"
# Override the global proxy/TTL defaults
- name: "direct.example.com"
proxied: false
ttl: 300
notifications:
telegram:
enabled: false
bot_token: ""
chat_id: ""
discord:
enabled: false
webhook_url: ""-h, --help: Show usage help.-s, --silent: Run without console output (ideal for Cron).-d, --debug: Enable verbose logging and API response output.-f, --force: Force an update even if the IP has not changed.
To run the updater every 5 minutes:
- Open crontab:
crontab -e - Add the line:
*/5 * * * * /path/to/cf-updater-linux-x86_64 --silent
There is no Windows binary: this program needs a real Bash, and no single-file static Bash exists for Windows. Run it from source under Git Bash, MSYS2 or WSL.
- Open Task Scheduler and "Create Basic Task".
- Name it "Cloudflare DNS Updater".
- Set Trigger to Daily, then in properties set "Repeat task every X minutes" (e.g., 5 or 10).
- Action: Start a Program.
- Program/script:
C:\Program Files\Git\bin\bash.exe - Add arguments:
-c "/c/path/to/Cloudflare-DNS-Updater/cloudflare-dns-updater.sh --silent"
For detailed instructions on building, testing, and understanding the project structure, please see CONTRIBUTING.md.
Quick start for building binaries:
- Validate Code:
./tools/validate.sh
- Build All Binaries:
Artifacts will be created in the
./tools/build-all.sh --all
dist/directory.