https://www.cloudflare.com/api.html?a=DIUP&hosts=dyn.example.com&u=user@example.com&tkn=your-cloudflare-api-key&ip=123.123.123.123
wget -qO- https://www.cloudflare.com/api.html?a=DIUP\&hosts=dyn.example.com\&u=user@example.com\&tkn=your-cloudflare-api-key\&ip=`wget -qO- http://automation.whatismyip.com/n09230945.asp`
#!/bin/bash
# set your user, token (key) name server and a comma-separated list of A records you want to change
CFU=joe@doe.com
CFP=435345245345346656
CFNS=jill.ns.cloudflare.com
CFHOSTS=me.doe.com
# get your current external ip address
CFIP=$(curl -s http://myip.dnsomatic.com/)
# build the url you need to do the update
CFURL="https://www.cloudflare.com/api.html?a=DIUP&hosts=$CFHOSTS&u=$CFU&tkn=$CFP&ip=$CFIP"
# find out the ip address listed in DNS for the first host in your list
CFHOSTIP=$(nslookup $(echo $CFHOSTS | cut -d ',' -f1) $CFNS | \
grep Address | tail -1 | cut -d ' ' -f2)
# if your current external IP are different from what shows in DNS do the update
if [ "$CFIP" != "$CFHOSTIP" ]
then
# use curl to do the dynamic update
/usr/bin/curl -s $CFURL
fi
curl https://www.cloudflare.com/api_json.html \
-d 'a=DIUP' \
-d 'tkn=8afbe6dea02407989af4dd4c97bb6e25' \
-d 'email=sample@example.com' \
-d 'ip=0.0.0.0' \
-d 'hosts=example.com,www.example.com,test.example.com'
We use essential cookies to make this site work, and optional cookies to enhance your experience.