Skip to content

Instantly share code, notes, and snippets.

@kusano
Created February 7, 2024 16:07
Show Gist options
  • Save kusano/856ecdb80fc7873405396de7f0fa5e3b to your computer and use it in GitHub Desktop.
Save kusano/856ecdb80fc7873405396de7f0fa5e3b to your computer and use it in GitHub Desktop.
ddns
TOKEN='...'
ZONE_ID='...'
DNS_RECORD_ID='...'
DOMAIN='hoge.example.com'
IP=$(curl https://checkip.amazonaws.com/)
curl \
--request PUT \
--url "https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records/${DNS_RECORD_ID}" \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer ${TOKEN}" \
--data '{
"content": "'${IP}'",
"name": "'${DOMAIN}'",
"proxied": false,
"type": "A",
"ttl": 3600
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment