Setting up dynamic DNS, port forwarding on DD-WRT

One of the nice features of Windows Home Server was that it would automatically setup dynamic DNS updates so I could access my home server (and other machines at my home through it) using a well known name even though my WAN IP address could keep changing. For e.g. I could go to foo.homeserver.com and that would give me a login screen which would then allow me TS access and file access to my home server and other machines.

Since moving to my Ubuntu home server, I’ve been wanting to set something similar up. The primary use case for me was to access a wireless camera in my home – I have my alarm system setup so it will call me in case any of the sensors are tripped and my plan was to then view the camera on my smartphone to figure out what was going on at home.

The first step is finding a good dynamic DNS service. A brief search led to me FreeDNS which is minimal and gets the job done for free. Simply sign up for an account and then go to Subdomains and pick your unique subdomain to refer to your WAN IP. You want to leave the type as A and pick a domain that’s owned by afraid.org and not contributed as that’ll give you more stability than a contributed domain. Now go to the main menu, click on Dynamic DNS, then Direct URL – don’t worry about any errors shown in the browser but what you want is the token that follows update.php? in the URL. Copy this and paste it somewhere you can get back to.

The next step is to setup DD-WRT so it can automatically update the DNS record with your WAN IP address for the subdomain we setup. As it turns out, this is really simple because DD-WRT supports FreeDNS out of the box. Go to Setup -> DDNS, in the drop-down pick freedns.afraid.org, put guest, guest for username/password and in the hostname, type in the subdomain you setup in FreeDNS followed by , and the token we got from above and save settings. At this point everything should be setup and working and the DDNS status should show you that the update worked.1 For better directions, see this.

Now, you can setup port forwarding – this basically allows you to forward traffic to certain ports to your WAN IP to an internal address on your network. In the NAT/QoS tab, select Port Forwarding and add an entry – pick TCP, leave Source Net empty, Port from to a value you’ll remember (a number below 65536), IP Address to an address inside your network and Port to to the port on the internal IP address that you want to reach (for e.g. 80 for a webserver inside your network).

Finally, if you have your own domain, you can also setup a subdomain that will automatically direct traffic to your WAN IP. I have a domain that’s registered with GoDaddy – by adding a CNAME entry that points a hostname on your domain to the subdomain you registered with FreeDNS, you’ll be able to reach your WAN IP with your own subdomain address. For e.g. if my own domain is mydomain.com, the FreeDNS subdomain I registered is foo.mooo.com, then adding a CNAME record that points home to foo.mooo.com will allow me to use home.mydomain.com to reach my WAN IP.


1. Note that the exact UI and options you see can be different based on the version of DD-WRT you are running. My instructions are based on DD-WRT build 22118 on my WZR-HP-G300NH

Leave a Reply

Your email address will not be published. Required fields are marked *