Skip to content

Instantly share code, notes, and snippets.

/cloudflare.sh Secret

Created January 13, 2018 14:31
#!/usr/bin/env sh
set -e
# 把下面的变量替换成你自己的信息
# API_KEY=
# EMAIL=
# ZONE_ID=
# DOMAIN=
# RECORD_ID=
PUBLIC_IP=$(curl -fs 'https://api.ipify.org?format=text')
curl -fs -o /dev/null -XPUT -H "X-Auth-Key: $API_KEY" -H "X-Auth-Email: $EMAIL" \
-H "Content-Type: application/json" \
"https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records/$RECORD_ID" \
-d "{
\"type\": \"A\", \"content\": \"$PUBLIC_IP\",
\"id\": \"$RECORD_ID\", \"name\": \"$DOMAIN\"
}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment