How do you check your external IP?

William Park opengeometry-FFYn/CNdgSA at public.gmane.org
Sun May 13 01:32:10 UTC 2012


On Sat, May 12, 2012 at 12:29:17PM -0400, William Park wrote:
> Hi all,
> 
> How do you check your external IP?  I know about <whatismyip.com>, but I
> would like to know other sites.
> 
> I usually go to my router's webpage.  But, my new router has fancy Java
> enabled webpage that I can't log in using Lynx.  So, I can't script it.
> My plan is to send email to myself if IP changes.  :-)

Ok, here is what I've able to collect.  Below script determines my
external IP (randomly from 6 sites), and emails to myself only if IP has
changed.  There are 3 parameters: EMAIL, NEW, OLD.  Right now, I have
it running every hour.  I could probably run it more frequently, but
/etc/cron.hourly is the shortest interval without writing my own
crontab.

#!/bin/sh

EMAIL=<your-email-address>	# your email address
NEW=~/checkip.new		# file containing new IP
OLD=~/checkip.old		# file containing old IP

case $(( $RANDOM % 6 )) in
    0) lynx -dump http://cfaj.freeshell.org/ipaddr.cgi ;;
    1) lynx -dump http://checkip.dyndns.org/ | grep 'Current IP Address:' ;;
    2) lynx -dump http://icanhazip.com/ ;;
    3) lynx -dump http://ipchicken.com/ | grep 'Name Address:' | sed -e 's/.*: \([0-9-]\+\).*/\1/' -e 's/-/./g' ;;
    4) lynx -dump http://myip.dnsdynamic.com/ ;;
    5) lynx -dump http://whatismyip.com/ | grep 'Your IP Address Is:' ;;
esac | tr -c -d '0-9.' > $NEW

if test -s $NEW && ! diff -q $NEW $OLD 1>/dev/null; then
    mutt $EMAIL -s "newip = $(< $NEW)" < /dev/null
    mv $NEW $OLD
fi

-- 
William
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list