Dynamic DNS (DDNS) on Asus routers

When using the stock or Merlin firmware on various Asus routers (I have an RT-N66U), you can use dynamic DNS to get a web domain to point to your router’s IP address.

To use dynamic DNS, do the following:

  1. Go to your router’s administration console (sometimes available at http://router.asus.com) and head to WAN > DDNS. There is also a link on the Network Map page.

  2. Enable the DDNS client, set Server to Custom and set the hostname to the web domain you will be updating (e.g. example.com).

  3. Connect to the router. I tend to enable SSH (and disable Telnet) via Administration > System.

  4. Create the script that will update your DDNS at /jffs/scripts/ddns-start. My favoured tactic here is to run:

     cat > /jffs/scripts/ddns-start
    

    Then paste the code, ensure the cursor is on a blank line (press Enter if not), then press Ctrl+D.

  5. Finally, ensure the script is executable:

     chmod +x /jffs/scripts/ddns-start
    

In my case, I’m updating an address using the http://afraid.org service. I get my private key from the dynamic section of the Afraid.org site, and I use a script taken almost verbatim from the Merlin wiki:

#!/bin/sh

curl "https://freedns.afraid.org/dynamic/update.php?<PRIVATE_KEY_HERE>"

if [ $? -eq 0 ]; then
    /sbin/ddns_custom_updated 1
else
    /sbin/ddns_custom_updated 0
fi