Skip to content

Instantly share code, notes, and snippets.

@ravage
Last active April 13, 2020 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ravage/9f671978efd8fa081c7acda074663201 to your computer and use it in GitHub Desktop.
Save ravage/9f671978efd8fa081c7acda074663201 to your computer and use it in GitHub Desktop.
asuswrt merlin cloudflare ddns update
#!/bin/sh
# /jffs/scripts/ddns-start
zone=<zone_id>
record=<record_id>
token=<bearer_token>
fqdn=<fqdn>
myip=$(/usr/sbin/nvram get wan0_ipaddr)
payload=$(cat <<EOF
{
"type":"A",
"name":"$fqdn",
"content":"$myip",
"ttl":1,
"proxied":false
}
EOF
)
curl -X PUT "https://api.cloudflare.com/client/v4/zones/$zone/dns_records/$record" \
-H "Authorization: Bearer $token" \
-H "Content-Type: application/json" \
-d "$payload" \
-s -f > /dev/null
if [ $? -eq 0 ]; then
/sbin/ddns_custom_updated 1
else
/sbin/ddns_custom_updated 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment