Friday, September 6, 2013

How to set up dynamic DNS in 5 minutes

With a dynamic DNS service (don't worry, there are free ones), you can use your domain name to point it to your home server, even if your home IP address changes sometimes. That way you can type in your browser and connect to your home network, or any other machine you configure.

All the guides I found for this simple task were actually really hard and required installing and configuring obscure/old software. I'll show you how to do it without installing anything and you can be running in about 5 minutes.

Of course, I assume you're on a Mac or Linux computer. If you're running Windows, you'll probably have to install something. Also, I used Namecheap's free, built-in dynamic DNS service, and it's the only one I've tried so far.

I bet you can get this done in 2 easy steps!

  1. Enable dynamic DNS (I'll show you how with Namecheap)
  2. Set up automatic updates so your domain points to your home (or whatever)

1. Enable dynamic DNS

A dynamic DNS service is one which has access to modify your domain name and update the host (IP address) it points to.

I mainly use Namecheap for my domain registrations. Conveniently, they also have a free dynamic DNS service. (There are plenty of paid ones out there, but you may not need their features. I don't.) What follows is how I do this on Namecheap, but any registrar with a similar service probably works similarly.

Click on the domain name in your Namecheap account and make sure the domain name's nameservers are pointed to Namecheap. Then click "All Host Records" in the menu. I want my entire domain to point to my home server, so I set @ and www like so:

Your host records might look something like this
You may choose to use only a subdomain, in which case you'd just fill out a new row below in a similar fashion with the sub-domain (host name) of your choice.

Either way, the IP address you enter isn't too important right now. I just chose

Save those settings, then click "Dynamic DNS" near the bottom of the menu:

Namecheap's built-in dynamic DNS works just fine
Make sure the "enable" option is checked and click the button to actually enable dynamic DNS.

Almost done! Keep that tab open, because we'll need the password given on that page.

2. Set up automatic updates

Now we just need to have "E.T. phone home" occasionally, so to speak. This means your home server will call out to your dynamic DNS provider and say "I'm here!" and give it your current IP address.

Most guides will tell you how to install and configure a dynamic DNS client -- but we're just going to use cURL and a cron job for this. (Okay, so if you don't have cURL already installed for some reason, then install it.)

If you're on Mac or Linux, this is easy enough with crontab. All you have to do is make a web request every so often. For example, you might add this to your crontab, if you're using Namecheap:

@hourly curl "`curl -s`"

(NameCheap's documentation.) You can choose how frequently to have it run. Now let me explain the URL which you need to customize:
  • HOST_NAME_HERE - This would be the host name from the "All Host Records" page. If you're using the whole domain name (, use @. If you're using the www prefix (, then add a cron job that's exactly the same except with the host of www. Otherwise, this value would be the sub-domain you chose to use and made the A record for.
  • YOUR_DOMAIN_HERE - This is your actual domain name, e.g.:
  • YOUR_PASSWORD_HERE - This is the password that Namecheap gives you on their "Dynamic DNS" page. 
The last parameter actually specifies the IP address to use. This little trick gets your public IP address using

It's important to note that anyone who has your password can set any host name on your domain with an A (Address) record to any IP address they want, effectively hijacking your domain name.

If you use another dynamic DNS provider or registrar, I'm not sure what the request URL would be for you. That's something you'd have to find out from the organization.

So there you go! Give it a few minutes (maybe a few hours) to propagate, and then your domain will be pointing to your own server.