On 6/14/05, Brad Bendily
Is there a script/package which can check the external IP on regular basis and send the changes to an email?
Is the host name consistent? If so, you can just do a dns lookup. If the host name changes with the IP, then that won't work. Another possibility, is a dynamic dns server, which many firewall/routes can be configured to use.
Here's a script that I made that at first I ran every 12 hours at my house. Until I made the script below that runs hourly. Also worth noting is that this stuff is running on RedHat 7.x
#!/bin/sh
FILE2=`echo "/fwlog/ifconfig.txt"`
touch /fwlog/ifconfig.txt ifconfig eth0 | grep inet | awk -F: '{print $2}' | sed 's/Bcast//' > /fwlog/ifconfig.txt mv -f /fwlog/ifconfig.txt $FILE2
cat $FILE2 | mail -s"IP address, ifconfig" email@gmail.com
I have another script that checks the ip and only sends an email if it's changed. This may be better for you. This runs hourly.
#!/bin/sh
ifconfig eth0 | grep inet | awk -F: '{print $2}' | sed 's/Bcast//' > /etc/fw/ipcheck
I=`cat /etc/fw/ip` #IP2=`cat /etc/fw/ipcheck` P=`cat /etc/fw/ipcheck`
#echo "My ip is $IP1" #echo "My ip is $IP2"
if [ "$I" != "$P" ]; then /etc/./ipshow /etc/fw/./fw rm -rf /etc/fw/ip cp /etc/fw/ipcheck /etc/fw/ip
#echo "My ip is $I" #echo "My ip is $P"
#else #exit 0 fi
Hi Brad, thanks a lot for the scripts. As in my situation, the external IP of the modem changes, not on the computer, I have modified the "get" part of your second script to: curl www.getip.com | grep title | awk -F':: ' '{print $2}' Now ... I guess I can understand what you have in the script so far ... :), but I do not see the sending part in the "if". Cheers Sunny