本文へスキップ

Cloudflare DDNS Updater

停滞
K0p1-Git/cloudflare-ddns-updater

動的 IP が変わったときに Cloudflare の DNS レコードを自動更新する、軽量で信頼性の高い Bash スクリプト。セルフホストのサービスに常にドメイン名でアクセスできます。

GitHub で見る
スター
1847
フォーク
440
ウォッチ
1847
未解決の Issue
4

この紹介文は現在英語版のみです。

A simple and effective BASH script for automatic Cloudflare DNS record updates

Overview

Cloudflare DDNS Updater is a lightweight BASH script designed to automatically update your Cloudflare DNS records when your home or server IP address changes. This solution enables you to access your self-hosted services through a consistent domain name, even with a dynamic IP address from your ISP.

Key Features

  • 🔄 Automatic IP Detection: Detects changes in your public IP address
  • 🔧 Easy Configuration: Simple setup with minimal requirements
  • 🔒 API Token Support: Uses secure Cloudflare API tokens
  • 🌐 IPv4 & IPv6 Support: Works with both address types
  • 📝 Detailed Logging: Optional logging for troubleshooting
  • ⏱️ Cron-Friendly: Easily scheduled through cron jobs
  • 📨 Email Notifications: Optional alerts for IP changes
  • 🛡️ Multiple Domain Support: Update records across multiple zones

How It Works

The script performs these basic steps:

  1. Detects your current public IP address
  2. Compares it with the existing DNS record in Cloudflare
  3. Updates the record only when a change is detected
  4. Provides optional logging and notifications

Quick Start

Prerequisites

  • A Cloudflare account with at least one domain
  • A server or device running a Linux distribution
  • Basic BASH and command-line knowledge

Setup Instructions

  1. Download the script:

    curl -o cloudflare-ddns-updater.sh https://raw.githubusercontent.com/K0p1-Git/cloudflare-ddns-updater/master/cloudflare-ddns-updater.sh
    chmod +x cloudflare-ddns-updater.sh
  2. Configure your settings: Edit the script and update the configuration variables:

    • Cloudflare API token or Global API key
    • Your email address
    • Zone ID (domain)
    • DNS record name
    • Record type (A for IPv4, AAAA for IPv6)
  3. Run the script manually:

    ./cloudflare-ddns-updater.sh
  4. Set up automatic updates: Add a cron job to run the script periodically (e.g., every 5 minutes):

    */5 * * * * /path/to/cloudflare-ddns-updater.sh

Advanced Configuration

Email Notifications

Configure email settings to receive notifications when your IP changes:

# Email Settings
EMAIL_TO="[email protected]"
SUBJECT="Cloudflare DDNS Updater - IP Changed"

IPv6 Support

The script can be configured to update AAAA records for IPv6 addresses:

# Set to either A or AAAA
TYPE="AAAA"

Proxied Records

Control whether Cloudflare should proxy your traffic:

# Set to either true or false
PROXIED="true"

Use Cases

  • Home Lab Access: Access your home lab services from anywhere
  • Self-hosted Websites: Keep your website accessible with a changing IP
  • Remote Access: Maintain remote access to your devices
  • Game Servers: Host multiplayer game servers with a consistent domain
  • IoT Devices: Connect to your smart home devices remotely

Troubleshooting

  • Verify API Permissions: Ensure your API token has the correct zone permissions
  • Check Logs: Enable logging to identify potential issues
  • IP Detection: If IP detection fails, try alternative IP services in the script
  • DNS Propagation: Allow time for DNS changes to propagate globally

Requirements

  • BASH shell
  • curl or wget for HTTP requests
  • Basic Linux command-line knowledge
  • Cloudflare account with domain

License

This project is licensed under the MIT License.


A reliable solution for maintaining access to your services with a dynamic IP address.

共通のカテゴリとタグで順位付けした、似たオープンソースプロジェクトです。

すべてのネットワークプロジェクト →