DynDNS type services; options, opinions and clients...

DJ Lucas dj at linuxfromscratch.org
Mon Oct 11 21:18:43 PDT 2004


Tartarus wrote:
> 
> I'm using dyndns.org and I wrote a simple client in perl that is run
> quite frequently by cron ...... (I perhaps run it too often but then I
> think my ISP changes my IP too often - up to 10 times a day).
> 
> Have had excellent service from dyndns.org and I am impressed with the
> qulity of their customer service and information (via their news
> server).
> 
> Dyndns.org only use HTTP for updates so nothing special should be
> required in your firewall or (NAPT) router.
> 
> Regards
> Tony
> 

Oh then something like my shell script would work, but I'd be interested 
to see your perl script too, as this is kind of a waste I think, because 
I couldn't find an easy way to get my external IP from my router. 
Actually, route might work.  Oh well.  It'd be interesting to see how 
you, as well as others have went about it.

-- DJ Lucas

-------------------------------------------------------------------------

#!/bin/sh
# Begin getip.sh

CURL="/usr/bin/curl"
SED="/bin/sed"
GREP="/bin/grep"
### Site hash is assigned by freedns (it's used in the update url)
SITEHASH="<INSERT SITEHASH HERE IF REQUIRED BY YOUR DDNS PROVIDER>"
TEMPFILE1="/tmp/getip-last.tmp"
TEMPFILE2="/tmp/getip-log.tmp"

echo ""

if [ -f "$TEMPFILE1" ]; then
         LASTIP=$(cat "$TEMPFILE1")
else
         LASTIP="0"
fi

IP=$("$CURL" -s www.whatismyip.com | "$GREP" '<h1>Your IP' | \
         "$SED"  's@<h1>Your IP is @@' | "$SED" 's@ <br></h1>@@')

echo "$IP" > "$TEMPFILE1"
echo "" > "$TEMPFILE2"

if [ "$IP" != "$LASTIP" ]; then
### Replace the update url below with your providers update url
         $CURL -s \
http://freedns.afraid.org/dynamic/update.php?"$SITEHASH"= \
 >> "$TEMPFILE2"
         if [ $? == 1 ]; then exit 1; fi
         grep "fail" "$TEMPFILE2"
         if [ $? == 0 ]
         then
                 echo "failed"
                 cat "$TEMPFILE2"
                 echo ""
                 exit 1
         else
                 exit 0
         fi
else
         echo "No update required!!!!"
         echo ""
         exit 0
fi

# End getip.sh



More information about the lfs-chat mailing list