I made a bash script to find your external ip address, and if it is different to the last time it checked it, it emails it to you.
It uses msmtp to send the email.
Code:
#/bin/bash
# email address which is sending the email
sender="user@domain.com"
# email address which is receiving the email
receiver="user@domain.com"
# delay time between checks in seconds
delaytime="1800"
# file to save previous ip address
oldip="/home/USER/.ip.address"
# temp file for email
tmpemail="/tmp/ip.mail"
touch $oldip
while true; do
rm -f $tmpemail
echo "To: $receiver" >> $tmpemail
echo "From: $sender" >> $tmpemail
echo "Subject: Your Ip" >> $tmpemail
echo "" >> $tmpemail
ipaddress=$(curl -s http://checkip.dyndns.org | sed 's/[a-zA-Z/<> :]//g')
ipaddress2=$(cat $oldip)
echo "Is: $ipaddress" >> $tmpemail
echo "Was: $ipaddress2" >> $tmpemail
echo $ipaddress
echo $ipaddress2
if [ "$ipaddress" != "$ipaddress2" ]
then echo "There different!"
cat $tmpemail | msmtp -a default $receiver
rm -f $oldip
echo $ipaddress >> $oldip
fi
echo "Continuing..."
sleep $delaytime
done
This is the first bash script that i've published
Bookmarks