Easy and free Dynamic DNS

- 3 mins read

The nasty need for dynamic DNS.

For a while now I’ve been maintaining a couple of 4G/5G enabled out of band devices. These devices are used to provide access to serial consoles of network devices. Why you ask? Well, sometimes a configuration error or something else causes the normal access paths to be unavailable. Who hasn’t made a L2 loop by accident…

I call these devices “last resort”. They provide a last resort access to my network when everything else fails, and they use 4G/5G for connectivity. The downside? They don’t have a fixed IP address, quite often the IPs change. For most cases this is fine because I have reverse tunnels, but I still want to access them in case those fail. But for that to work I need to know 1 crucial thing: its IP address on the internet.

I’m sure many people have used a service like “dyn.com” to solve this problem, the device in question sends a HTTP request (we wish those devices support HTTPS…) and a DNS record gets updated with the IP of the requesting device. That way every time the IP changes the DNS record gets updated and we can access it using the DNS name and it makes it easy to monitor its availibility. The main problem I had with this solution is the cost (also the annoying ratelimiting, but I partially blame the devices in question), it was not worth the money to use “dyn.com” for something I can make myself, right?

So I made a service myself.

When I started to think about this had the following requirements:

  • Dead simple to request a new dynamic hostname
  • No need for accounts
  • Compatibility with DynDNS style updates (/nic/update) (more to add?)

When I had the requirements clear I also wanted to make it stateless, who wants to keep track of what hostnames are in use and not? If you lose the credentials, just get a fresh hostname. I quickly wrote an implementation using FastAPI and looked in my unused domain invenstory for a good candidate.

I present to you: XYZ.FRL

Now the initial version of this service is deployed I really like it myself, mainly because how simple it is. You want to know how simple? Open your terminal and come along.

Request a new dynamic hostname

› curl -s https://xyz.frl/generate | jq .
{
  "hostname": "4bd36fd6538b45b3b5449e615afc8e21.xyz.frl",
  "username": "4bd36fd6538b45b3b5449e615afc8e21",
  "password": "+MihUvQ8pc1QwYA6/16A/D/155qHfJKlUqUhNgD6osE="
}

Update the hostname with a new IP

Simple use curl to send an update request and set the ip to the valuse set in the myip query param (you can also leave it out to use the IP the request is coming from).

› curl -s --user '4bd36fd6538b45b3b5449e615afc8e21:+MihUvQ8pc1QwYA6/16A/D/155qHfJKlUqUhNgD6osE=' 'http://xyz.frl/nic/update?myip=192.0.2.0,100::'

Check your new IP!

It might take a brief moment for changes to propagate

› host 4bd36fd6538b45b3b5449e615afc8e21.xyz.frl
4bd36fd6538b45b3b5449e615afc8e21.xyz.frl has address 192.0.2.0
4bd36fd6538b45b3b5449e615afc8e21.xyz.frl has IPv6 address 100::

Profit.

From now simply use your compatible client (or curl) with our without the myip query param to update the IP address in the record. Make your own life easy by simply CNAMEing to this hostname and you should be good to go.

Final thoughts

This was a small fun project that I threw together on a Saturday morning when I got a renewal notice (and now cancellation) for DynDNS. I hope it can benefit others too.

Do you have any ideas to make this service even better? Contact me on me@dj.vg.

Security

While I’ve applied pretty aggressive rate limiting (1 request per minute on the generate and update endpoints) it’s of course possible people might try to abuse this, if that happens I’ll deal with it.