I’ve been a user of DynDNS for my dynamic dns needs over a decade, and it’s a been a great way to maintain an online web presence, even when all I had was a sporadic dial-up account to TOJ (OG Jamaican developers know what I mean). This site has been on Dyn almost since they first started providing free dynamic dns accounts.
Imagine my chagrin to be informed that DynDNS is reducing the number and type of free accounts that they provide, and in order to maintain your free account, you must sign in to the DynDNS web portal at least once a month! This is in addition to the already existing condition that your dynamic dns ip has to be updated monthly in order to keep the account alive. Not such great news – who is going to remember to manually login to a web page every month? (That may be the point, since once your free account expires, you are encouraged to buy a premium account).
I’ve copied some other online resources and tweaked them a bit for an automated mechanism that signs in to DynDNS and sends a quick email to notify you that all is well (or not).
Here’s the details:
dyn_account_check.ksh
#!/bin/bash
################################################
#
# dyndnslogin
# Automate login to prevent account expiration
#
################################################
# DynDNS Settings
USERNAME=`cat ~/.dyn_account_info`
PASSWORD=`echo $USERNAME|cut -f2 -d’ ‘`
USERNAME=`echo $USERNAME|cut -f1 -d’ ‘`
################################################
# Variabeln PROGNAME=dyndnslogin
COOKIE=`mktemp –tmpdir=”/tmp” -t ${PROGNAME}_cookie_***XXXX`
OUTPUT=`mktemp –tmpdir=”/tmp” -t ${PROGNAME}_output_***XXXX`
USERAGENT=”Mozilla/5.0″
ERROR_RECIPIENTS=duane.cato@eschateq.com,duanecato@yahoo.com,duane.cato@gmail.com
################################################
# Main
MULTIFORM=`curl -s -k -A $USERAGENT -c $COOKIE https://account.dyn.com \ | awk –
F\’ ‘/multiform/{ print $6 }’`
curl -s -k –location -A “$USERAGENT” -b $COOKIE -c $COOKIE -o $OUTPUT \–data ”
username=$USERNAME&password=$PASSWORD&iov_id=&sub mit=Log+in&multiform=$MULTIFORM” \https://account.dyn.com/
#get just the user portion
USER_PFX=`echo $USERNAME |cut -f1 -d’@’`
if grep -E -i “(Welcome|Hi).*$USER_PFX” $OUTPUT > /dev/null 2>&1
then
echo “`date`: Dyn Login successful”
echo “`date`: Dyn Login successful” > /tmp/empty.txt
mailx -s “`date`: Dyn Login successful” -a $OUTPUT < /tmp/empty.txt $ERROR_RE CIPIENTS else echo “`date`: Dyn Login failed” echo “`date`: Dyn Login failed” > /tmp/empty.txt
mailx -s “`date`: Dyn Login failed” -a $OUTPUT < /tmp/empty.txt $ERROR_RECIPIENTS
FAILED=”true”
fi
rm $COOKIE
rm $OUTPUT
if [ “$FAILED” = “true” ]
then
exit 1
fi
# EOF
Pretty straight forward, I added a little bit of security obfuscation and notification logic, but this is mostly ripped from someone else – many thanks! Stick a call to this script in your crontab (or other scheduling solution). Hopefully, this helps others keep their free DynDNS going smoothly. On a side note, after looking through Dyns’ offerings, I realized they are quite cost competitive in their provision of domain and mail delegation services, and ended up going with them for another project. When possible, I may speak a little on using them as a pluggable cloud-based enterprise infrastructure component – I had a very positive experience. More to come.