Created
August 18, 2018 00:39
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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