English / [简体中文]
-
API Token
Obtain it by visiting https://dash.cloudflare.com/profile/api-tokens. Grant the token with DNS modification permissions and read permissions for ZONE and Zone Settings. -
Email
Log in to the Cloudflare email account. -
ZONE_ID
Zone ID (Go to Cloudflare, click on the corresponding domain, and then click on Overview to find the ID on the bottom right).
# Obtain from https://dash.cloudflare.com/profile/api-tokens
TOKEN="aabbccddeeffgghhllmm"
# Log in to the Cloudflare email account
EMAIL="[email protected]"
# Zone ID (Go to Cloudflare, click on the corresponding domain, and then click on Overview to find the ID on the bottom right)
ZONE_ID="aabbccddeeffgghhllmm"
# Domain to be resolved (e.g., gmail.com or www.gmail.com)
DOMAIN="www.google.com"
# IP type (A/AAAA)
TYPE="AAAA"
DAYS_TO_KEEP=7
#Execute
crontab -e
#Insert
# Run every 5 minutes
*/5 * * * * /opt/script/cloudflare_ddns/cloudflare_ddns.sh >/dev/null 2>&1
- Attention
- The domain to be resolved must already exist.
- Before running, please check if the curl and jq commands are available.
- Some systems may encounter issues with the curl command (such as certificate not found issues; for OpenWRT, you can use opkg install --force-reinstall ca-bundle to fix it).
- Since only the IP address and domain name have changed before updating the DNS record, if other configurations are modified, delete the data.json file and restart the script again