Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Update Cloudflare DNS Record with Dynamic IP
#!/bin/sh
CF_TOKEN=""
ZONE_ID=""
SITE_ID=""
DNS_RECORD="foobar.com"
PUB_IP=$(dig @1.1.1.1 ch txt whoami.cloudflare +short | cut -d\" -f 2)
curl -XPUT "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records/$SITE_ID" \
-H "Authorization: Bearer $CF_TOKEN" -H "Content-Type: application/json" \
-d "{\"type\":\"A\",\"name\":\"$DNS_RECORD\",\"content\":\"$PUB_IP\",\"ttl\":1,\"proxied\":true}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment