Skip to content

Instantly share code, notes, and snippets.

@Paulomart
Created July 10, 2015 11:15
Show Gist options
  • Save Paulomart/721700fe09c889a39485 to your computer and use it in GitHub Desktop.
Save Paulomart/721700fe09c889a39485 to your computer and use it in GitHub Desktop.
zone="example.com"
sub="subdomain" # subdomain
email="fuu@example.com" # your cloudflare email
token="xxxxxxxxxxxxxx" # you api key
rid="xxx" # record id, find it with https://www.cloudflare.com/docs/client-api.html#s3.3 3.3 - "rec_load_all" - Retrieve DNS Records of a given domain
IP=$(curl http://icanhazip.com/)
echo "Setting cloudflare dns $sub.$zone to $IP"
curl https://www.cloudflare.com/api_json.html -d 'a=rec_edit' -d "tkn=$token" -d "id=$rid" -d "email=$email" -d "z=$zone" -d 'type=A' -d "name=$sub" -d "content=$IP" -d 'service_mode=0' -d 'ttl=1'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment