Skip to content

Instantly share code, notes, and snippets.

@allegrem
Created January 6, 2015 20:31
Show Gist options
  • Save allegrem/8f1736ed2966d4596779 to your computer and use it in GitHub Desktop.
Save allegrem/8f1736ed2966d4596779 to your computer and use it in GitHub Desktop.
homemade dyndns
#!/bin/bash
# this one mails you the ip if it changes
T1=`curl -s icanhazip.com`
touch old_ip.dat
read T2 < old_ip.dat
if [ "$T1" = "$T2" ]; then
echo "`date` -- ipchange script -- IP is the same: $T1 - doing nothing " | tee -a /var/log/syslog
else
(echo "From: FROM@gmail.com"; echo "To: TO@gmail"; echo "Subject: IP Address Update"; echo; echo "Computer's IP Changed. The new IP is:"; echo $T1) | sendmail -f FROM@gmail.com TO@gmail.com
fi
echo $T1 > old_ip.dat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment