Skip to content

Instantly share code, notes, and snippets.

@v1ct0rv
Created August 28, 2015 21:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save v1ct0rv/9a2a33f868981db6f797 to your computer and use it in GitHub Desktop.
Save v1ct0rv/9a2a33f868981db6f797 to your computer and use it in GitHub Desktop.
Update clodflare record from command line
# List Cloudflare zones and copy the zone do you want to update
curl -X GET "https://api.cloudflare.com/client/v4/zones?name=example.com&status=active&page=1&per_page=20&order=status&direction=desc&match=all" \
-H "X-Auth-Email: cloudflere_email" \
-H "X-Auth-Key: cloudflare_apikey" \
-H "Content-Type: application/json"
# List DNS Records paste the zone from previous command
curl -X GET "https://api.cloudflare.com/client/v4/zones/paste_here_zone_id/dns_records?type=A&page=1&per_page=20&order=type&direction=desc&match=all" \
-H "X-Auth-Email: cloudflere_email" \
-H "X-Auth-Key: cloudflare_apikey" \
-H "Content-Type: application/json"
# Update Dns Record this command can be put on a cronjob.
wget -qO- http://checkip.amazonaws.com | xargs -I {} curl -X PUT "https://api.cloudflare.com/client/v4/zones/paste_here_zone_id/dns_records/paste_here_record_id" \
-H "X-Auth-Email: cloudflere_email" \
-H "X-Auth-Key: cloudflare_apikey" \
-H "Content-Type: application/json" \
--data '{"id":"372e67954025e0ba6aaa6d586b9e0b59","type":"A","name":"example.com","content":"{}","proxiable":true,"proxied":false,"ttl":120,"locked":false,"zone_id":"paste_here_zone_id","zone_name":"example.com","created_on":"2014-01-01T05:20:00.12345Z","modified_on":"2014-01-01T05:20:00.12345Z","data":{}}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment