Debian - Automate Monthly Connexion for Dyndns Free Accounts



For so many years, has been providing free dynamic DNS accounts. For me, they have been the 'de facto' dynamic DNS provider. The proof : so many home routers, NAS, ... manufacturers are providing update clients for their DNS service.

But this wonderful time has come to an end. Dyn has simply removed any free offer from their catalog and thanks to their latest SLA, you are now supposed to connect to their web server at least once a month to keep your existing free dyndns account active. Even with an update client, your free account may be terminated if you do not connect periodically to their web site. This new policy is a deliberate free account killer.

If, like me, you've been relying for ages on their service for your personal web site, this new policy is a real pain in the neck. Who will think to connect once a month to a site to do ... nothing ? Hopefully (as usual in the computing world) there is a solution : instead of you in person, a small shell script can peridically to do the connection job for you. It will automatically connect to Dyn web site using your account.

So, this article explains how to create and setup a periodic script that will connect to Dyn login page. This connexion will be considered by Dyn as a user connexion. As a result, you'll be able to keep your free dyndns account active even without doing yourself the newly needed monthly connexion. This periodic script should allow you to save your free account from a killing SLA.

It has been designed on a Debian 7 server, but it should work on any Linux system.

The connexion script is heavily based on the very good work done on this blog site.

1. Web Connexion Script

The web site connexion script is quite simple in tis principle :

  • it takes a Dyn login and password as parameters
  • it simulates a browser connexion with user interaction
  • it logs the result

As the connexion result may be crucial for your free account survival, it can also send a success or failure notification email, by using sendmail client.

Email notification will only be sent if recipient email address has been defined. If needed, a sendmail configuration guide is available.

# --------------------------------------------------------
# Script to connect to dyndns web site
# It should be run every week to be compatible
# with new policy for free accounts
# Based on 
# Parameters :
#  $1 - Login
#  $2 - Password
#  Revision history :
#   06/10/2013, V1.0 - Creation by N. Bernaerts
# --------------------------------------------------------

# ---------- Beginning of user defined parameters -------------
# address where the mail should be sent
# keep it empty if you don't want notification mail
# name of the email sender (whatever you want)
MAIL_FROM="Dyndns web script"
# subject of the mail
MAIL_SUBJ="Login to for"
# ---------------- End of user parameters ---------------------

# setup

# parameters for dyndns login
DYN_UA="Mozilla/5.0 (Windows NT 6.0) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.112 Safari/535.1"

# temporary files
TMP_LOG=$(mktemp -t dyndns-XXXXXXXX.log)
TMP_EMAIL=$(mktemp -t
TMP_COOKIES=$(mktemp -t dyndns-XXXXXXXX.cookie)

# ------------------------------------------
#     Connect to dyndns account page
# ------------------------------------------

# init log file
echo "Account $DYN_ACCOUNT" > $TMP_LOG 

# fetching initial headers
echo "Fetching initial headers to pre-load cookies..." >> $TMP_LOG
curl -b $TMP_COOKIES -c $TMP_COOKIES -Ikso "$DST" -A "$DYN_UA" --url "$DYN_LOGIN"

# fetching UID
echo "Fetching UID..." >> $TMP_LOG
VALUE=$(curl -b $TMP_COOKIES -c $TMP_COOKIES -kso - -A "$DYN_UA" --url "$DYN_LOGIN" | grep -m 1 "multiform" | cut -d"'" -f 6)

# posting data
echo "Read UID as '$VALUE' - posting data..." >> $TMP_LOG
curl -b $TMP_COOKIES -c $TMP_COOKIES -d "username=$DYN_ACCOUNT" -d "password=$DYN_PASSWORD" -d "iov_id" -d "multiform=$VALUE" -e "$DYN_LOGIN" -kso "$DST" -A "$DYN_UA" --url "$DYN_POST"

# verifying result
echo "Response received - verifying result..." >> $TMP_LOG
curl -b $TMP_COOKIES -c $TMP_COOKIES -e "$DYN_POST" -kso - -A "$DYN_UA" -H "Accept-Language:$DYN_LANGAGE" --url "$DYN_CHECK" | grep -qE "<span>(Welcome|Hi) <b>$DYN_ACCOUNT</b></span>" && RESULT="Success" || { RESULT="Failed"; }

# display & log result
MESSAGE="$RESULT while connecting to $DYN_ACCOUNT account"
logger $MESSAGE

# ------------------------------------------
#        Send notification mail
# ------------------------------------------

if [ "$MAIL_DEST" != "" ]
  # prepare the mail body
  echo "to:$MAIL_DEST" > $TMP_EMAIL
  echo "from:$MAIL_FROM" >> $TMP_EMAIL
  echo "subject:$RESULT - $MAIL_SUBJ $DYN_ACCOUNT" >> $TMP_EMAIL

  # append the declaration log to the mail body
  echo "$MESSAGE" >> $TMP_EMAIL
  echo "" >> $TMP_EMAIL
  echo "------------ log -------------" >> $TMP_EMAIL
  echo "" >> $TMP_EMAIL
  cat $TMP_LOG >> $TMP_EMAIL

  # send the mail
  cat $TMP_EMAIL | sendmail -t

# ------------------------------------------
#        Cleanup temporary files
# ------------------------------------------


Script can be retreived directly from Github :

# wget -O /usr/local/sbin/dyndns-web-connect
# chmod +x /usr/local/sbin/dyndns-web-connect

You can now test your scripted web connexion :

# dyndns-web-connect yourlogin yourpassword
Success while connecting to yourlogin account

2. Weekly Update Script

Now that scripted connexion works, you only need to automate it.

As Dyn is asking for a monthly connexion, lets do it on a weekly basis to be on the safe side.

This weekly task can be setup very easily with the help of anacron.

# weekly connexion to dyndns web site 

# set PATH

# connect to your dyndns account
dyndns-web-connect yourlogin yourpassword

You just need to retreive the script, place it under /etc/cron.weekly and make it executable :

# wget -O /etc/cron.weekly/dyndns-weekly
# chmod +x /etc/cron.weekly/dyndns-weekly

Your weekly web connexion is now planned.

You should now be fully compliant with the new Dyn policy for legacy free accounts :-)


Hope it helps.

Signature Technoblog

This article is published "as is", without any warranty that it will work for your specific need.
If you think this article needs some complement, or simply if you think it saved you lots of time & trouble,
just let me know at This email address is being protected from spambots. You need JavaScript enabled to view it.. Cheers !

icon linux icon debian icon apache icon mysql icon php icon piwik icon googleplus