SRV Records – How do I use them correctly?
Definition of an SRV record
With a Service Resource Record (short: SRV record) you can make services, which are usually available via an IP:PORT combination, reachable using a DNS host name. Important to note regarding SRV record is the fact, that they only work if an application has been specifically programmed to make use of them. Examples for this are TeamSpeak3 or Minecraft. SRV-Records can not be used to point a DNS name to an IP address/port combination for arbitrary use by any application.
Example - Teamspeak:
Usually TeamSpeak is using the protocol UDP over port 9987. If you are running a TeamSpeak instance with the IP 18.104.22.168 every client that wants to connect has to enter the IP:port combination of 22.214.171.124:9987. If you change the port or the server IP, you have to inform everyone about the new combination. With SRV records it is possible to connect to TeamSpeak using a DNS host name like ts.mydomain.com
In general every SRV record contains the same information:
_SERVICE._PROTOCOL.yourdomain.tld 86400 IN SRV PRIORITY WEIGHT PORT SERVER
In this example:
_ts3._udp.ts.mydomain.com 86400 IN SRV 0 5 9987 ts.mydomain.com
Values for priority and weight can usually be left at their defaults, they are only used if two or more SRV records with the same name exist. Please note that for the data field, you cannot simply add an IP address here. Instead, you will have to add a valid DNS host name which in turn resolves to an IP address by using an A record, so make sure that the host name you set there exists.
How to create an SRV record at Contabo
- Log in into your Contabo customer control panel using https://my.contabo.com
- Using the menu item "DNS Zone Management" you can edit a DNS zone and create a new record
- The type has to be SRV
- Fill in the form. An example can be seen below (please click on the picture in order to increase its size):
- The finished record should look like this:
From now on your users can connect to TeamSpeak using only the subdomain ts.mydomain.com
For Minecraft, the record may look like this:
_minecraft._tcp.mc.mydomain.com 86400 IN SRV 0 5 25565 server01.mydomain.com
Please make sure to consult the documentation of your service or application regarding whether SRV records are supported and what scheme they should use.