Here is something I did a while ago. I haven't used it in a while. It looks like you'll have to create a directory called /etc/ipcheck/ . Just put the checkip somewhere and create a cron job to run it however often you want. Then put the mailmessage in the /etc/ipcheck directory you created. Make sure both of the files are executable.
Here is the file checkip
Code:
#!/bin/bash
#
/sbin/ifconfig eth1|grep "inet addr" > /etc/ipcheck/ipcheck.tmp
diffout=`diff --brief /etc/ipcheck/ipcheck /etc/ipcheck/ipcheck.tmp | awk '{ print $1 }'`
if [ -z $diffout ]; then
# if diffout is empty (files match)
rm -f /etc/ipcheck/ipcheck.tmp
else
rm -f /etc/ipcheck/ipcheck
mv -f /etc/ipcheck/ipcheck.tmp /etc/ipcheck/ipcheck
ipstring=`cat /etc/ipcheck/ipcheck | awk '{ print $2 }'`
/etc/ipcheck/mailmessage YOUREMAIL@DOMAIN.TLD $ipstring
fi
Here is the file mailmessage
Code:
#!/bin/bash
#
mail -s "Your IP Address Has Changed!" $1 << EOF
This is your new IP is $2
EOF