DNS SRV Records to the Rescue

Like everyone else I do have technical debt or stumble over things when changing my infrastructure that I didn’t see coming. Recently, it hit me when I wanted to change the physical location of one of my Prosdy XMPP servers I use for personal communication. Getting the XMPP server VM to a bare metal host at another physical site was done in a few minutes and at first I thought my plan worked nicely. The warm feeling didn’t last very long, however.

The final part of relocating the service was to change the DNS records for my XMPP service. The catch: At the site I wanted to host the virtual machine I only have a dynamic public IP address and my router only allows me to change one domain name when the public IP changes. The fix that works for (almost) everything: I use DNS CNAME entries for the services behind the dynamic public IP address which all point to the one domain name my router updates with the dynamic IP address when it changes. This works great for subdomains such as xmpp.martin-home.com, but I discovered that it does not work for root domains, e.g. martin-home.com. Looks like this is by design.

And, as you have probably guessed by now, the XMPP server I moved uses a root domain. As a quick fix I just put the current dynamic IP address into the DNS record so the service would become usable again. But obviously, this was not a permanent fix. In the past, I updated individual domain names instead of a single one by having a script for each (sub)-domain that checked if the public IP in front of the NAT has changed, which in turn triggered an update of the DNS A and AAAA records. This worked but I didn’t want to go back there.

But then I remembered that a friend uses DNS SRV (service) records for his XMPP server. These are queried by XMPP clients and other XMPP servers before the normal DNS A or AAAA records. Only if the DNS SRV records are not found would the A and AAAA records used. And…, most importantly, SRV records point to domain names! In other words SRV records are a sort of CNAMEs which can be used for subdomains and root domains! Great! So I created the following SRV records for the root domain I use for my XMPP server:

_xmpp-client 5222
_xmpp-server 5269

Both SRV records are now pointing to the single domain name I update when the dynamic public IP address changes and are properly queried by the two clients I use for XMPP: Dino on Linux and Conversations / Quicksy on Android. Siskin on the iPhone works as well. All very nice!

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.