#!/bin/sh EMAIL="Your CloudFlare E-mail address" ## uncomment next line if you using Global API Key #API="Your Cloudflare API Key" ## comment next line if you using Global API Key TOKEN="Your Cloudflare API Token with just enough permission" ZONEID="Your zone id, hex16 string" RECORDID="You DNS record ID, hex16 string" RECORDNAME="Your DNS record name, e.g. sub.example.com" RECORDTTL="Your DNS record TTL in second (1=auto, Must be between 120 and 2147483647)" IP=${1} if [ "$TOKEN" != "" ]; then AUTH_HEADER="Authorization: Bearer ${TOKEN}" else AUTH_HEADER="X-Auth-Key: ${API}" fi RES=`curl -ks -X PUT "https://api.cloudflare.com/client/v4/zones/${ZONEID}/dns_records/${RECORDID}" \ -H "X-Auth-Email: ${EMAIL}" \ -H "${AUTH_HEADER}" \ -H "X-Auth-Key: ${API}" \ -H "Content-Type: application/json" \ --data "{\"type\":\"A\",\"name\":\"${RECORDNAME}\",\"content\":\"${IP}\",\"ttl\":${RECORDTTL},\"proxied\":false}"` # accroding to docs, it OK to remove ttl and proxied parameters # https://api.cloudflare.com/#dns-records-for-a-zone-update-dns-record echo $RES | grep '"success":\ *true' > /dev/null if [ $? -eq 0 ]; then /sbin/ddns_custom_updated 1 else /sbin/ddns_custom_updated 0 fi