Skip to content

Instantly share code, notes, and snippets.

@joet3ch
Created December 22, 2012 19:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joet3ch/4360659 to your computer and use it in GitHub Desktop.
Save joet3ch/4360659 to your computer and use it in GitHub Desktop.
cloudflare ddns
#!/bin/sh
# modified by jfro from http://www.cnysupport.com/index.php/linode-dynamic-dns-ddns-update-script
# Uses curl to be compatible with machines that don't have wget by default
# modified by Ross Hosman for use with cloudflare.
cfkey=
cfuser=
cfhost=
WAN_IP=`curl -s http://ip.skafari.com`
if [ -f $HOME/.wan_ip-cf.txt ]; then
OLD_WAN_IP=`cat $HOME/.wan_ip-cf.txt`
else
echo "No file, need IP"
OLD_WAN_IP=""
fi
if [ "$WAN_IP" = "$OLD_WAN_IP" ]; then
echo "IP Unchanged"
else
echo $WAN_IP > $HOME/.wan_ip-cf.txt
echo "Updating DNS to $WAN_IP"
curl -s https://www.cloudflare.com/api.html?a=DIUP\&hosts="$cfhost"\&u="$cfuser"\&tkn="$cfkey"\&ip="$WAN_IP" > /dev/null
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment