Dynamic DNS

3 minute read

So it winds up that the RaspberryPI I set up to serve doesfloydshavezombie.com still didn’t have a static IP after all…

The Problem

I thought I had set up a static IP through my router by just clicking “use static IP” in the router’s config… but every few days the internet would go out and I would have to switch back to the default of a dynamically assigned IP. My ISP was reassigning me a new IP every few days, even though I had selected “static IP” through my router. What gives?

What was Happening

I didn’t understand what requesting a static IP really entailed… when I clicked “use static IP address” in my router config, I was just locking down the IP that was currently assigned from my ISP. That IP could still change from under me, and when it did, my internet would go out.

How to fix it?

To actually get a static IP, you need to contact your ISP to have one assigned to you and then assign this manually in your router’s config. This costs extra $$, at least for static IPs assigned by Comcast.

Instead, I learned about DynamicDNS, which is a way for a domain to stay up to date with the changing IP of the device to which it is mapped. DDNS works by getting IP updates from a ddns client that runs on a device on your network. The client periodically sends the current IP address of the device to the DNS provider: If the IP sent by the client is different than the one currently mapped to the domain, the DNS provider will update the mapped IP to the new value.

This is essentially an automated way of keeping a domain up to date with a dynamically changing IP. An alternative to DDNS might be to manually update an IP with your DNS provider whenever it changes… but there will surely be more downtime and dissatisfied users with this approach since your sites will be inaccessible during this time.

What I did

I explored a few options:

  1. My router had the capability to assign itself a free DDNS domain name through NoIP. Because this functionality was baked in to my router, I didn’t actually need to install a client on my server to send updates when the IP changed: the router took care of this for me. Once I finished setting up NoIP, though, I realized that I couldn’t map the domain name that I had hosted on namecheap easily to NoIP (unless I transferred it and paid 30 dollars for their paid service tier) so this wasn’t going to be my end solution.

  2. Namecheap, my DNS provider, offered a DDNS solution for domains hosted with it! Enabling Dynamic DNS for a domain hosted on name cheap was as easy as flipping a switch in the config for the domain. This gave me a DDNS password, which I passed to a 3rd party DDNS client called ddclient. ddclient was super easy to configure, could be run as a daemon, and was automatically launched as such when my server reboots. I configured it to send IP update info to Namecheap every 5 minutes – in other words, if my IP changes there will be a maximum of 5 minutes of downtime between the update. 5 minutes over the course of ~4 days (the average time between Comcast assigning me a new IP) equals 1 - (5 / (4 * 24 * 60)) == .9991319% uptime. This is a perfectly acceptable solution for my current needs, but had I required a higher uptime guarantee I could either reduce the duration between updates from the client. Alternatively I could just pony up the $$ and request a static IP from Comcast.

Conclusion

I found this entire process was needlessly complicated to set up, because the documentation I found was very poorly written and I felt like I was constantly missing details. After digging in to it for an evening, though, I now feel like I have a good grasp on how DDNS works.

Had I realized that Namecheap offered a DDNS solution for domains registered with it, I wouldn’t have bothered messing with NoIP. The NoIP ddns client was very poorly packaged, difficult to install and configure, and didn’t seem to actually work for the short amount of time I messed with it. Ddclient on the other hand could be installed via apt-get and set up daemons + run on startup tasks out of the box. Definitely a good learning experience.

Leave a Comment