Quote:
|
Originally Posted by tk_ ...
I'm looking for a way to get the WAN IP address (not the LAN) of the modem, since it changes irregularly.
I know I can type in the LAN IP address of the modem and view the IP address on the modem's web page, but I need to be able to get it in text form that I can then either email or FTP it somewhere (i.e. to me at another location). Right now, getting the IP in a text format is the hard part.
I'm hoping for either a script or small program that is simple (and free).
... |
Were you to be running Linux the script is a one-liner! And is about as simple, and free, as you can get!
Code:
wget -qO - http://whatismyip.org/
This can be adapted in a sh script to do most anything you could want to do with an IP address; a script such as the following gets the WAN and LAN IPs, updates my dynamic DNS service and emails me the log. Its run as cron job to go however often it is needed.
MyIPDetailsQuery.sh
Code:
# write a new log each day
myDate=`date +%Y%m%d`
# set up log file
ipFileName="/tmp/ip-details-$myDate.log"
echo "===== IP DETAILS LOG =====" >> $ipFileName
echo "" >> $ipFileName
date >> $ipFileName
# external IP
wget -qO - http://whatismyip.org/ >> $ipFileName
echo " : external IP addr" >> $ipFileName
# internal IP
/sbin/ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1, " : internal IP addr" }' >> $ipFileName
echo "- - - - - BEGIN no-ip OUTPUT - - - - -" >> $ipFileName
sudo /usr/local/bin/noip2 -S >> $ipFileName 2>&1
echo "- - - - - END no-ip OUTPUT - - - - -" >> $ipFileName
# email the result
/bin/mail -s "IP details query" myadmin@mydomain.com < $ipFileName
If you are not running Linux, then
wget is available for Windows (goto sourceforge.net) and I imagine it would not be impossible to produce a BAT file to do the same/similar - although I haven't bothered trying (why bother, when it's so much easier with Linux

).