<- back to Blog

Setting up a DynDNS

Coffee of the day: an upsetting espresso March 14, 2025

Today my ISP decided to change my public IP yet again. This caused both of the game servers that I’m running to no longer be accessible by my friends.

The challenges

There are two caveats to hosting a game server that often cause trouble. The more common hurdle is figuring out how to open ports on your router. Depending on its model and your ISP, this may or may not turn out to be much of a problem.

Another challenge is allowing users outside your network to connect to the server. For that you’d usually want to share your public IP address with them. This bothered me. And because I’ve been playing around with DNS servers for my local network recently, I knew that it’s possible to assign a neat domain name to the IP and use that instead of the less convenient IP address.

So I set out and arranged a subdomain for one of my domains. I assigned an A Record to it pointing to terraria as a the subdomain and I assigned my public IP address to it. Thus, terrara.my-domain.com was born and I could easily share it with my friends for them to connect to the game server.

A few weeks passed and out of the blue I get a message that a friend can no longer join the server. I check the logs and everything is running just fine. Eventually I discover that my public IP address had changed.

Being the lazy cave troll that I am not being in the mood of digging deeper, I simply changed the IP I had assigned to the subdomain to my newly assigned public IP. I did not change the TTL and punished everyone by making them wait about half an hour to see the change propagate. And that was that - the server was accessible again!

Until a week later…

It happened again. What a bummer… Now my cave troll brain is reaching for its imaginary beater. There has to be a better way to solve this! This is hwo I came across the idea of a Dynamic DNS. With DynDNS, the IP address gets assigned to a DNS record much like how I’ve been manually doing. However, with DynDNS, it all happens automatically.

The setup was surprisingly straight forward. All I had to do is set up a DDNS client - ddclient. I then just followed the documentation of the domain registrar on how to configure it. One thing that I didn’t initially grasp was that when you’re specifying subdomains, you have to spell out the full address including the root domain. So an example config would look like something like this:

use=web
web=dynamicdns.park-your-domain.com/getip
protocol=namecheap
server=dynamicdns.park-your-domain.com

login=yourdomain.com
password=your dynamic dns password
subdomain1.yourdomain.com


login=yourdomain.com
password=your dynamic dns password
subdomain2.yourdomain.com

ddclient itself is running as a Docker container. The example docker-compose file can be found on my homelab page.

Once the client was set up and the config was correct, I could see that the IP of the subdomain records automatically updated to the correct public IP within the domain dashboard. Pretty magical!

Then I briefly changed the TTL from Automatic to 1 Minute - lesson learned. A minute later, I could check the IP of the subdomain by executing something like this:

$ nslookup subdomain1.example.com 1.1.1.1

Which returned the correct public IP that had been automatically assigned by ddclient. Afterwards, I changed the TTL back to Automatic. I noticed that after the dynamic assignment of the IP executed, the TTL had also changed to Automatic anyway.

And that’s it! All that’s left is to see if the client will correctly assign a new IP to the subdomains automatically whenever they change again.


Written by Nedko Chulev