Last active
April 14, 2020 11:59
-
-
Save nexus166/c0777ee394fd7d70e451c51fe3866684 to your computer and use it in GitHub Desktop.
Cloudflare DNS Zone A/AAAA update
This file contains hidden or 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/bash -eu | |
| EMAIL="[email protected]"; | |
| APIKEY="xyz"; # https://dash.cloudflare.com/<account_id>/profile/api-tokens | |
| ZONE="abc"; # https://dash.cloudflare.com/<account_id>/<zone> | |
| RECORDID=$(curl -fso- -H "Authorization: Bearer ${APIKEY}" -H "Content-Type: application/json" "https://api.cloudflare.com/client/v4/zones/${ZONE}/dns_records?name=${1}" | jq -crM '.result[].id'); | |
| curl -fso- \ | |
| -H "Authorization: Bearer ${APIKEY}" \ | |
| -H "Content-Type: application/json" \ | |
| -X PUT "https://api.cloudflare.com/client/v4/zones/${ZONE}/dns_records/${RECORDID}" \ | |
| --data ' | |
| { | |
| "id": "'${RECORDID}'", | |
| "name": "'${1}'", | |
| "type": "'${2:-A}'", | |
| "content": "'${3:-$(curl -fso- icanhazip.com)}'" | |
| }' | jq |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment