Skip to content

Instantly share code, notes, and snippets.

@fennifith
Created August 18, 2018 00:39
Show Gist options
  • Save fennifith/817428c8b984e35845f25ff8157996ca to your computer and use it in GitHub Desktop.
Save fennifith/817428c8b984e35845f25ff8157996ca to your computer and use it in GitHub Desktop.
Shell script using the CloudFlare API to update the value of a CNAME record to match a server's public IP address.
ip="$(dig +short myip.opendns.com @resolver1.opendns.com)"
curl -X PUT "https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records/${RECORD_ID}" \
-H "X-Auth-Email: email@example.com" \
-H "X-Auth-Key: ${AUTH_KEY}" \
-H "Content-Type: application/json" \
--data "{\"type\":\"CNAME\",\"name\":\"example.com\",\"content\":\"${ip}\"}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment