Created
March 20, 2022 19:29
-
-
Save marshyski/02d027cb87c8e2dd71c03b7083d0aeb0 to your computer and use it in GitHub Desktop.
Update Cloudflare DNS Record with Dynamic IP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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