Skip to content

Instantly share code, notes, and snippets.

@rmrf-run
Forked from kevinoconnor7/c-ddns.sh
Created September 26, 2016 19:11
Show Gist options
  • Save rmrf-run/489f16ebc2ee8f682c891ec78ca74062 to your computer and use it in GitHub Desktop.
Save rmrf-run/489f16ebc2ee8f682c891ec78ca74062 to your computer and use it in GitHub Desktop.
CloudFlare Dynamic DNS
#!/bin/sh
WAN_IP=`curl ifconfig.io/ip`
OLD_WAN_IP=`cat /var/CURRENT_WAN_IP.txt`
if [ "$WAN_IP" = "$OLD_WAN_IP" ]
then
echo "IP Unchanged"
else
curl https://www.cloudflare.com/api_json.html \
-d 'a=rec_edit' \
-d 'tkn=8afbe6dea02407989af4dd4c97bb6e25' \
-d '[email protected]' \
-d 'z=example.com' \
-d 'id=9001' \
-d 'type=A' \
-d 'name=sub' \
-d 'ttl=1' \
-d "content=$WAN_IP"
echo $WAN_IP > /var/CURRENT_WAN_IP.txt
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment