#!/bin/bash
APIKey=""
Email=""
zone_identifier=""
identifier=""
name="xxx.domain.ouo"
while true
do
NewIP=$(curl -6s ifconfig.io)
test -e ip.txt && OldIP=$(<ip.txt) || echo $NewIP > ip.txt
[ "$NewIP" != "$OldIP" ] && curl -sX PUT "
https://api.cloudflare.com/client/v4/zones/$zone_identifier/dns_records/$identifier" -H "X-Auth-Email: $Email" -H "X-Auth-Key: $APIKey" -H "Content-Type: application/json" --data "{\"type\":\"AAAA\",\"name\":\"$name\",\"content\":\"$NewIP\"}" > /dev/null && echo $NewIP > ip.txt && echo "Update IP: $NewIP"
sleep 5
done