Why would someone want to do this? Well I wanted to do this because my ISP (internet service provider) changes my IP address every 3-6 months for an unknown reason (security?). This makes it hard to host your own webserver. After some searching, I found this script and modified it to my own liking, since it didn’t quite work right when I first got it. I am NOT assuming responsibility if some goofball breaks their computer because they don’t know know what they are doing. Please realize that you will need to install wget and sendmail if you don’t already have them on your Unix system. I will not get into installing these packages in this post. To get this working you will need to set up a cron job to run this script every hour. If the IP hasn’t changed it will not send an email. Here is more information how to set up your cron jobs. Please refer to my last post to send text messages to your cell phone vie email. There is more than enough information on the given websites for the packages. Here is the original script.
Here is my Bash Script which is named ip_change.sh
#!/bin/bash
#########################################################################
#-----------------------------------------------------------------------#
#########################################################################
touch old_ip.dat
wget halfzware.com/whatismyip.php
SITE=$"whatismyip.php"
SENDER=$"Little@Gremlins.com"
RCVR=$"5745551234@vtext.com"
RCVR2=$"YOUR_EMAIL@gmail.com"
read T1 < $SITE
read T2 <old_ip.dat
IP=$(cat $SITE)
if [ "$T1" = "$T2" ]; then
echo "IP Is the same doing nothing:";
else
echo "From: $SENDER"; echo "To: $RCVR"; echo "Subject: IP Address Update"; echo; echo "Computer's IP Changed. The new IP is:"; echo $IP | sendmail -f $SENDER $RCVR; echo $IP | sendmail -f $SENDER $RCVR2;
fi
echo $IP
rm old_ip.dat
mv $SITE old_ip.dat
cory,
hey cory,
seattle is cool, and you wish you were here!!!! ahahahaha
you could play with your computers all day!!!!
haha
peace out!
g