I’ve noticed that DSN SRV records are something that are not very common knowledge among even some of the really techy people. Well, the reason is probably that most people never need to know what they actually are. I’m gonna explain them here briefly and show how I set the DNS SRV records for my XMPP server hosted at Slicehost.com.
Ok, so what these DNS SRV records are. If you’re familiar with the DNS MX record you know that it is used to indicate where is the email server that is hosting a certain domain. For example, I have domain service.com and I’m running my webserver at www.service.com and my email server is at smtp.service.com. Naturally, I would want my users to have email addresses like firstname.lastname@example.org. Here I would set the DNS MX record to point to smtp.service.com so when email servers communicate with each other they can ask from DNS server that “where is the email server for domain service.com?”.
DNS SRV records were specified for a bit more general purpose than MX records that can be used with email only. You might have XMPP server at xmpp.service.com and would like your users have also XMPP address of the format email@example.com. This is how the SRV records for the XMPP look like. This is an example of SRV records I’ve set for my XMPP server at teemu.im.
_xmpp-client._tcp.teemu.im. 82698 IN SRV 10 0 5222 teemu.im.
_xmpp-server._tcp.teemu.im. 86400 IN SRV 10 0 5269 teemu.im.
What there actually mean? Well, the
_xmpp-client._tcp.teemu.im. line is the line that XMPP clients use to ask from DNS that “where I can find the XMPP server for domain teemu.im?”. The DNS server responds that “the XMPP server can be found from host teemu.im port 5222″. The other line that has
_xmpp-server._tcp.teemu.im. is used by the XMPP servers when they talk to each other using the XMPP server-to-server protocol, similarly as the email servers use the MX records to find out information about each other.
The SRV records can also be used to do “poor mans load balancing” by using the priority and weight attributes, but I won’t go in to that now. Instead, I’ll show you how you can configure DSN SRV records on Slicehost.com server. This is because I use Slicehost, but the same principles apply for other hosting providers as well.
First, go to your SliceManager and login. There choose the “DNS” tab and you should see something like this:
Now click “Records” and then “new record”. Fill the form as shown below:
Note that the value in “Name” field starts with underscore although it is not visible in the screenshot.
Do the same for the server-to-server protocol, except for the name set
_xmpp-server._tcp.domain.com. and for the data use
0 5269 domain.com..
You can use tool called
dig for testing your configuration. Type the following line to see if your configuration is correct:
dig @ns1.slicehost.net SRV _xmpp-client._tcp.domain.com
The result should be:
;; ANSWER SECTION:
_xmpp-client._tcp.domain.com. 86400 IN SRV 10 0 5222 domain.com.
By the way… when configuring DNS it is good to set the time-to-live value to something relatively small. In case you make mistakes, you don’t need to wait until the DNS record will be updated. Other good practice is to use the
@nameserver.domain.com parameter for
dig command so that the entry does not propagate to other DNS servers and you can change it pretty much when ever you want.