Skip to content

Instantly share code, notes, and snippets.

@dvl
Created November 23, 2016 16:48
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 dvl/082d6052c7d15b6acd5ca22c77efe626 to your computer and use it in GitHub Desktop.
Save dvl/082d6052c7d15b6acd5ca22c77efe626 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -x
EMAIL=''
API_KEY=''
ZONE_ID=''
RECORD_ID=''
CURRENT_IP=`dig +short myip.opendns.com @resolver1.opendns.com`
HOST='home.host.tld'
curl -X PUT "https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records/${RECORD_ID}" \
-H "X-Auth-Email: ${EMAIL}" \
-H "X-Auth-Key: ${API_KEY}" \
-H "Content-Type: application/json" \
--data "{\"type\": \"A\", \"name\": \"${HOST}\", \"content\": \"${CURRENT_IP}\"}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment