使用教程

#!/bin/sh

# GET Recore ID
#curl -x get "https://api.cloudflare.com/client/v4/zones/YOUR_ZONE_ID/dns_records" \
#-h "x-auth-email:[email protected]" \
#-h "x-auth-key:YOUR_GLOBAL_API_KEY" \
#-h "content-type: application/json"


NEW_IP=`curl -s http://ipv4.icanhazip.com`
CURRENT_IP=`cat /tmp/current_ip.txt`

if [ "$NEW_IP" = "$CURRENT_IP" ]
then
        echo "No Change in IP Adddress"
else
curl -X PUT "https://api.cloudflare.com/client/v4/zones/YOUR_ZONE_ID/dns_records/YOUR_RECORD_ID" \
     -H "X-Auth-Email: [email protected]" \
     -H "X-Auth-Key: YOUR_GLOBAL_API_KEY" \
     -H "Content-Type: application/json" \
     --data '{"type":"A","name":"YOUR-DDNS.exampel.com","content":"'$NEW_IP'","ttl":120,"proxied":false}' > /dev/null
echo $NEW_IP > /tmp/current_ip.txt
fi