Traceroute -R can sometimes provide your external IP address.
(This should be moe efficient that fetching a remote web page.)
Here is an example line.
ping -R www.cw.net -c 2 cat -n awk '{if ($1==4) print $2}'
Showing posts with label wan ip address. Show all posts
Showing posts with label wan ip address. Show all posts
Saturday, 1 September 2007
shell script to update dynamic dns using record route.
You do not need to fetch a page from whatismyip.com to get your own public IP address, traceroute -R (record route) may also give you the address of your WAN information.
A shell script like this might work if you add it to a cron job.
Be careful not to get banned. You must only update your records if your address has changed.
Read the rules at dyndns.org.
#!/bin/sh
ping -R www.cw.net -c 2 cat -n awk '{if ($1==4) print $2}' > newip
if [ `cat newip` != `cat previp` ]; then
wget http://"username:password@members.dyndns.org/nic/update?system=dyndns&hostname=www.yyyyyyy.com,yyyyyy.com&myip=`cat newip`"cat update*system*rm update*system*
fi
cp newip previp
exit
A shell script like this might work if you add it to a cron job.
Be careful not to get banned. You must only update your records if your address has changed.
Read the rules at dyndns.org.
#!/bin/sh
ping -R www.cw.net -c 2 cat -n awk '{if ($1==4) print $2}' > newip
if [ `cat newip` != `cat previp` ]; then
wget http://"username:password@members.dyndns.org/nic/update?system=dyndns&hostname=www.yyyyyyy.com,yyyyyy.com&myip=`cat newip`"cat update*system*rm update*system*
fi
cp newip previp
exit
Labels:
dynamic dns.,
record route,
shell,
traceroute,
wan ip address
Subscribe to:
Posts (Atom)