Skip to content

Instantly share code, notes, and snippets.

Forked from dd-han/
Created March 11, 2018 06:17
What would you like to do?
using Cloudflare as DDNS in ASUSWRT-Merlin firmware

ASUSWRT-MERLIN custom DDNS Script for Cloudflare

for Cloudflare as DDNS

using Cloudflare API v4


put ddns-start at /jffs/scripts/, setting values and set DDNS type to Custom at web Admin panel.


EMAIL is your Cloudflare account

API is your Cloudflare API Key. You can find at My Setting -> API Key -> Global API Key -> View API Key

ZONEID can find by following command

curl -X GET "" \\
    -H "X-Auth-Email: $EMAIL" \\
    -H "X-Auth-Key: $API" \\
    -H "Content-Type: application/json"

RECORDID can find by following command

curl -X GET "${ZONE}/dns_records?page=1&per_page=1000&order=type&direction=asc" \\
     -H "Content-Type:application/json" \\
     -H "X-Auth-Key: $API" \\
     -H "X-Auth-Email: $EMAIL"

RECORDNAME is target domain name like

RECORDTTL is record TTL in minute (1=auto)

if you don't want skip SSL check, run opkg install ca-certificates and change command from curl -ks to curl -s


EMAIL="Your CloudFlare E-mail address"
API="Your Cloudflare API Key"
ZONEID="Your zone id, hex16 string"
RECORDID="You DNS record ID, hex16 string"
RECORDNAME="Your DNS record name, e.g."
RECORDTTL="Your DNS record TTL (1=auto)"
RES=`curl -ks -X PUT "${ZONEID}/dns_records/${RECORDID}" \
-H "X-Auth-Email: ${EMAIL}" \
-H "X-Auth-Key: ${API}" \
-H "Content-Type: application/json" \
--data "{\"type\":\"A\",\"name\":\"${RECORDNAME}\",\"content\":\"${IP}\",\"ttl\":${RECORDTTL},\"proxied\":false}"`
echo $RES | grep '"success":\ *true' > /dev/null
if [ $? -eq 0 ]; then
/sbin/ddns_custom_updated 1
/sbin/ddns_custom_updated 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment