Created
September 18, 2013 12:49
-
-
Save Phunky/6608695 to your computer and use it in GitHub Desktop.
Check every hour if external IP has changed and if so update DNS record on linode - simple dynamic dns ;)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
LINODE_API_KEY= | |
DOMAIN_ID= | |
RESOURCE_ID= | |
WAN_IP=`curl -s http://icanhazip.com/` | |
if [ -f $HOME/.wan_ip.txt ]; then | |
OLD_WAN_IP=`cat $HOME/.wan_ip.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.txt | |
echo "Updating DNS to $WAN_IP" | |
curl -s https://api.linode.com/?api_key="$LINODE_API_KEY"\&api_action=domain.resource.update\&DomainID="$DOMAIN_ID"\&ResourceID="$RESOURCE_ID"\&Target="$WAN_IP" > /dev/null | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment