[ale] Comcast DHCP
Scott McDonald
twopeanuts at gmail.com
Thu Mar 29 17:41:22 EDT 2007
>Atlanta Linux Enthusiasts wrote:
>> So I
>> wrote a script that runs every few minutes, it checks ifconfig output,
>> hacks it up with grep and awk, writes it to a tmp file, compares with
>> the old tmp file, and IF my ip has change it then uses lynx to call a
>> zoneedit.com url to update my zones with my new IP.
>
>I'm sure that was fun, but why not use http://ddclient.sourceforge.net/
>, http://zoneclient.sourceforge.net/ , or http://inadyn.ina-tech.net/?
>
>-Brian
Well... ddclient and zoneclient I had not heard of before...
I had heard of ez-ipupdate, so I started there. Looking for docs to
set it up I saw a lot of hits from people saying not to use it, to use
inadyn. So I tried apt-get install inadyn and there it was. Then I
started looking for docs on getting inadyn to work with zoneedit, and
didn't get very far... so I dropped back to man inadyn, and there was
a ton of stuff to read, and I'm lazy... so instead I had 10 mins of
fun throwing this together, which works great for me.
Thanks,
-Scott
-----
#!/bin/sh
#
# JSM: dydns.sh - quick zoneedit.com update for dynamic ip when it changes
# JSM: drop this script in /root/dydns/ directory and run it from cron
every 5 mins
# JSM: change the UsErNaMe:PaSsWoRd and host in the update urls
#
GATEWAYIPADDRESS="/root/dydns/ipaddress"
GATEWAYIPADDRESSOLD="/root/dydns/ipaddress.old"
/sbin/ifconfig | /usr/bin/head | /bin/grep "inet addr" | /usr/bin/awk
'{print $2}' | /usr/bin/awk -F: '{print $2}' > $GATEWAYIPADDRESS
if [ $? -ne 0 ]
then
echo "Cannot ifconfig beyotch"
exit
fi
# make sure successful
if [ -f $GATEWAYIPADDRESS ]
then
# assume at first that IP address has not changed
IPCHANGED="no"
# check if there is an old address to compare to
if [ -f $GATEWAYIPADDRESSOLD ]
then
# checks to see if they are different
diff $GATEWAYIPADDRESS $GATEWAYIPADDRESSOLD | grep "." > /dev/null
if [ $? -eq 0 ]
then
# OK, we know they are different
# set the change variable appropriately
IPCHANGED="yes"
rm $GATEWAYIPADDRESSOLD
mv $GATEWAYIPADDRESS $GATEWAYIPADDRESSOLD
fi
else
# else just create the old $GATEWAYIPADDRESSOLD file
mv $GATEWAYIPADDRESS $GATEWAYIPADDRESSOLD
# set the change variable appropriately
IPCHANGED="yes"
fi
# Now send the message if the ip address has indeed been changed
if [ $IPCHANGED = "yes" ]
then
lynx -source -auth=UsErNaMe:PaSsWoRd
http://dynamic.zoneedit.com/auth/dynamic.html?host=twopeanuts.com
# what to do in case of failure
if [ $? -ne 0 ]
then
echo "Error browsing to Zoneedit"
rm $GATEWAYIPADDRESSOLD
exit
fi
lynx -source -auth=UsErNaMe:PaSsWoRd
http://dynamic.zoneedit.com/auth/dynamic.html?host=dancestuffetc.com
# what to do in case of failure
if [ $? -ne 0 ]
then
echo "Error browsing to Zoneedit"
rm $GATEWAYIPADDRESSOLD
exit
fi
fi
# Problems reading/writing to the file
else
echo "Cannot access $GATEWAYIPADDRESS"
fi
More information about the Ale
mailing list