A Bash-based script to automatically update Cloudflare DNS records with your dynamic public IP address. Designed for efficiency and compatibility across Linux, macOS, and Windows.
- 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: Runs on Linux, macOS, and Windows (via bundled binaries or Bash).
- 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 are available that bundle all necessary dependencies (Bash, Curl, JQ).
- 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) - Windows:
cf-updater-windows-x86_64.exe
- 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.yamlExample cloudflare-dns.yaml:
---
cloudflare:
zone_id: "your_zone_id_here"
api_token: "your_api_token_here"
options:
proxied: true # true for Orange Cloud (Proxy), false for DNS only
ttl: 1 # 1 for Auto, or value in seconds (60-3600)
interface: "" # Optional: Force specific interface (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 global proxy setting
- name: "direct.example.com"
proxied: false
notifications:
telegram:
enabled: false
bot_token: ""
chat_id: ""
discord:
enabled: false
webhook_url: ""-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
- 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: Browse to
cf-updater-windows-x86_64.exe. - Add arguments:
--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.