« Photo of the Month - July 2007 | Exchange 2003 monitoring with PowerShell (WMI) »

Use tinyget to determine your external IP address

Here's what we're trying to do:

I wanted to send myself a periodic e.mail to @gmail.com with my external IP address, both to keep a log of IP's used, and to recover in case my dynamic DNS registration fails for some reason. And of course, Google's nearly unlimited MB size is perfect for this electronic clutter !

I first wrote this script to pull my external IP address off my Linksys router. Shortly thereafter, I replaced the Linksys box with shorewall on a Linux distro. I could do ifconfig and SED the IP out, and I still might, but I may as well finish what I've started in batch.


Requirements:

  • A command line SMTP mail utility like bmail, or postie would be helpful. I used to use postie a lot, but bmail does 80% of the features for free. This script is written for bmail.
  • Tinyget.exe from the IIS 6.0 Resource Kit. With Tinyget.exe, you can do amazing things from the command line. (Kind of like w-get* and wput in one).

Here's the sample script:

@echo off
cls
::REM Sample batch script from www.japan-page.net/batch
echo.
echo Determine my IP address...
echo.

::REM Grab IP off the net...

::REM Note we are dropping a few extra lines of text with the find filter here.

tinyget -d www.ippages.com /simple/ | find /v "alternate" >_out.txt

::REM Send it out by e.mail...

set _too=me@gmail.com
set _frm=me@mydomain.com
set _sbj="IP Address"
set _hst=mySMTPserver

bmail -s %_hst% -t %_too% -f %_frm% -a %_sbj% -h -d -c -m _out.txt>_log.txt

echo done.


This script relies on www.ippages.com which offers a free IP lookup service. Note, you are limited to 200 queries per day, so don't run this every 60 seconds.

See this article on how to update www.easydns.com dynamic dns with a batch script and tinyget.exe.

Have fun.



With Zoundry, I can't put the word w-get (spelled properly without the hyphen) in a posting without causing it to fail. Go figure.

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)