DynDNS Monthly Login Script for TomatoUSB (14)

    January 1st, 2014 | Tags: , , , , | Posted in Guides, Tech

    DynDNS Monthly Login - Dyn Free Account SLA Update

    DynDNS Monthly Login – Dyn Free Account SLA Update

    DynDNS.org (Dyn) changed their free hostname(s) policy – accounts using free hostname(s) need to manually log in to their accounts every month (or 30 days) to prevent their hostname(s) from expiring and being deleted. Using an update client will no longer suffice. To workaround tackle this limitation, I have put together a script to automate the DynDNS monthly login. In fact, this automated script performs DynDNS login every week.



    1. TomatoUSB-enabled router like ASUS RT-N66URT-N16, Linksys E4200ASUS RT-AC66U.
    2. Flashed to TomatoUSB firmware (I am using TomatoUSB on my RT-N66U and RT-AC66U).
    3. Curl binary for TomatoUSB
    4. Geeky mind to do some troubleshooting


    Setting up curl’s URL

    The TomatoUSB firmware does not come with curl binary required for this DynDNS monthly login script to work. Hence, we will need to place the curl binary on a accessible location (preferably web host / Dropbox) to allow the TomatoUSB router retrieve it when required.

    Note: This DynDNS monthly auto login script requires curl to work. This script makes use of wget to download curl from the URL. The wget on TomatoUSB does not support https URL.

    For this guide, we will use dropbox to distribute the curl binary required for the script. You can also place it on your web host (if you have one).

    1. Download Curl binary for TomatoUSB.
    2. Unpack the package and upload it to your webhost or the public folder of your Dropbox.
    3. Note down the public link / URL to the location of curl on your webhost or Dropbox without the https (e.g. http://dl.dropbox.com/u/curl).


    Inserting the DynDNS Monthly Login Script

    1. Using a web browser, login to the TomatoUSB web administration page.
    2. Navigate to Administration -> Scripts -> WAN Up tab. If the WAN Up tab has been used for AdBlock for TomatoUSB, you can use the Init tab instead.
    3. Copy and paste the contents below into the text area.
    4. Update the contents of both USERNAME and PASSWORD (line 13 and 14) with the details of your DynDNS account.
    5. Update the content of CURL_URL (line 17) with the public link / URL to the location of curl (step 3 from previous section).
    6. Save and reboot the router.


    Verifying the script is running

    1. After the TomatoUSB router has rebooted, ssh into the router.
    2. Verify that DDNS_LOGIN.sh is created by typing “ls /tmp” without the quotes.
    3. Verify that the DDNS_LOGIN script is running by typing “cat /var/log/messages | grep DDNS_AUTOLOGIN” without the quotes.
      It should show that the login was successful or unsuccessful
    4.  Congratulations! The DynDNS monthly login script is running!


    Understanding the DynDNS Auto Login Script

    DynDNS Account Details

    The DynDNS account details are captured by the following variables. Do ensure the account information are correct.


    curl for TomatoUSB

    Curl is not available on TomatoUSB. In this script, we are using curl to do the HTML form post for the DynDNS login. To make curl available on the TomatoUSB router, we will place the curl binary on a web accessible URL and have the script download it when required. The curl binary is placed in /tmp and will be gone after a power cycle.



    User Agent

    We will want DynDNS to think that we are logging in to DynDNS manually. Hence, we will need to masquerade as a web browser. In this script, the user-agent is set to Chrome. For the geeks, you can freely change the content of this variable to reflect the user-agent that you like to spoof / masquerade.


    Running the script every Sunday 2305 hrs

    The script runs automatically every Sunday at 2305 hrs. For the geeks, this is a cron entry through cru so you can freely change the frequency or the time it executes the DynDNS auto log in to your preference.



    Treat shadowandy!

    If these step-by-step guides have been very helpful to you and saved you a lot of time, please consider treating shadowandy to a cup of Starbucks.  

    14 responses

    1. This looks a lot better than a lot of the scripts out there for DYNdns login, but when I try the “test” procedure, it fails authentication. I am sure my login info is correct, I even coped/pasted it into the DYNdns login page manually to make sure it works. Here is what I get from the SSH test-

      Tomato v1.28.0000 MIPSR2-103 K26 USB Max
      root@unknown:/tmp/home/root# ls /tmp
      DDNS_LOGIN.sh home script_wanup.sh var
      curl mnt share
      etc pptpd splashd
      root@unknown:/tmp/home/root# cat /var/log/messages | grep DDNS_AUTOLOGIN
      Jan 29 19:58:01 unknown user.notice root: DDNS_AUTOLOGIN – Login Unsuccessful

      Any ideas?

    2. bobz,

      As mentioned through email, will need you to comment off line 44 (the rm $OUTPUT) line and paste me the contents of /tmp/DDNSAL.output.

    3. Thank you. The dyndns auto login is working on my asus n66u.

    4. # Location of curl binary

      Instead of public url, can this be pointing to a folder located in a USB hard disk drive connected to the Tomato Router? If so, can you provide a working example?


    5. MY,

      Just set the CURL_EXE variable to point to the location of the curl on the usb disk. The codes on line 25 to 28 will skip the download if it finds a executable named curl at the location of CURL_EXE.

    6. I placed the file under:

      I get
      Mar 9 12:10:32 XXXXX user.notice root: DDNS_AUTOLOGIN – Login Unsuccessful

      When I execute the command from Tomato Tools, System page, I get:

      /tmp/DDNS_LOGIN.sh: line 23: /tmp/curl: Permission denied
      /tmp/DDNS_LOGIN.sh: line 25: /tmp/curl: Permission denied
      rm: can’t remove ‘/tmp/DDNSAL.cookie’: No such file or directory
      rm: can’t remove ‘/tmp/DDNSAL.output’: No such file or directory

      /tmp/curl folder contains 660 kb curl file without any extension and an empty folder named:__MACOSX

    7. MY,

      Can you execute “/tmp/curl –version” and paste me the version and details?

      If it fails to execute, do ensure that /tmp/curl is set to be executable.

    8. I get this:

      root@XXXXXX:/tmp/home/root# /tmp/curl –version
      -sh: /tmp/curl: Permission denied

    9. I had another curl at this location:
      SO, I changed the code as above. Now, I don’t get the “Permission denied” anymore. I commented the lines as follows to see if outputs are generated.
      # rm $COOKIE
      # rm $OUTPUT

      I think the issue is with this line:
      if grep -E “(Welcome|Hi).*$USERNAME” $OUTPUT > /dev/null 2>&1; then

      OUTPUT file does not have “Welcome|Hi” in it.
      When I login to my account, I don’t see “Welcome|Hi”.

      There is Welcome and my username.

    10. MY,

      The Welcome|Hi is actually regular expression so it matches either Welcome or Hi. Do you see that the login is successful in your router logs?

    11. No, not with
      if grep -E “(Welcome|Hi).*$USERNAME” $OUTPUT > /dev/null 2>&1;

      I changed it to read:
      if grep -E “Welcome” $OUTPUT > /dev/null 2>&1;
      Then it is successful.
      I played with every combination of “(Welcome|Hi).*$USERNAME” . It did not work. When I login, I see Welcome XYZ, where XYZ is the username.
      If you can explain ().*, that may be helpful.

    12. I figured out the problem. My Username to login the account is mixed case like: XYz. After logging in to the website, username is converted to lowercase. OUTPUT file contains “Welcome xyz”.
      If I type in
      then your code works.

    13. MY,

      Thanks for troubleshooting. Cos my username is in lowercase so didn’t realise that DynDNS actually represents the username in lowercase. Glad that it works for you. :)

    14. Hi shadowandy,

      Can you write a similar script for no-ip.com. It also requires users to login monthly. I am not sure if a simple login is sufficient or not to keep the account active. It may be necessary to click on “Modify”, then “Update” for each host name.



    Recent Posts


    Treat shadowandy!

    If these step-by-step guides have been very helpful to you and saved you a lot of time, please consider treating shadowandy to a cup of Starbucks.  


    Recent Comments

    Friend's Blog

    Interesting Links

    Previous Postings