Skip to content

Instantly share code, notes, and snippets.

@pinglamb
Created June 12, 2016 11:00
Show Gist options
  • Save pinglamb/f86084b8c5e726d49b78dd43cad3aabf to your computer and use it in GitHub Desktop.
Save pinglamb/f86084b8c5e726d49b78dd43cad3aabf to your computer and use it in GitHub Desktop.
Cloudflare ASUS Custom DDNS Script
#!/bin/sh
EMAIL= # Your Email
ZONEID= # Your zone id, hex16 string
RECORDID= # You DNS record ID, hex16 string
RECORDNAME= # Your DNS record name, e.g. sub.example.com
API= # Cloudflare API Key
IP=${1}
curl -fs -o /dev/null -XPUT "https://api.cloudflare.com/client/v4/zones/$ZONEID/dns_records/$RECORDID" \
-H "X-Auth-Email: $EMAIL" \
-H "X-Auth-Key: $API" \
-H "Content-Type: application/json" \
--data "{\"id\":\"$RECORDID\",\"type\":\"A\",\"name\":\"$RECORDNAME\",\"content\":\"$IP\",\"zone_id\":\"$ZONEID\"}"
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