Skip to content

Instantly share code, notes, and snippets.

@mgax
Created May 2, 2018 18:54
Show Gist options
  • Save mgax/bee21220771ee79cfdc9b3539452f8b5 to your computer and use it in GitHub Desktop.
Save mgax/bee21220771ee79cfdc9b3539452f8b5 to your computer and use it in GitHub Desktop.
#!/bin/bash -e
auth_email='my email'
auth_key='my auth key'
zone_id='my zone id'
record_id='my record id'
name='my record name'
addr="$(curl -f -s myip.redcoat.grep.ro)"
url="https://api.cloudflare.com/client/v4/zones/$zone_id/dns_records/$record_id"
body='{"type":"A","name":"'$name'","content":"'$addr'","ttl":1,"proxied":false}'
curl -X PUT "$url" \
-H "X-Auth-Email: $auth_email" \
-H "X-Auth-Key: $auth_key" \
-H "Content-Type: application/json" \
--data "$body" \
-f -s -o /tmp/ddns.log \
|| (echo "dns update failed"; exit 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment