The SRV record is used for special services like VoIP.
After reading this article you will be able to:
Copy article link
The DNS "service" (SRV) record specifies a host and port for specific services such as voice over IP (VoIP), instant messaging, and so on. Most other DNS records only specify a server or an IP address, but SRV records include a port at that IP address as well. Some Internet protocols require the use of SRV records in order to function.
In networking, ports are virtual places that designate what processes network traffic goes to within a computer. Ports allow computers to easily differentiate between different kinds of traffic: VoIP streams go to a different port than email messages, for instance, even though both reach a computer over the same Internet connection. Much like IP addresses, all ports are assigned a number.
Certain Internet protocols, such as IMAP, SIP, and XMPP, need to connect to a specific port in addition to connecting with a specific server. SRV records are how a port can be specified within the DNS.
An SRV record contains the following information. Here, we list example values for each field.
service | XMPP |
proto* | TCP |
name** | example.com |
TTL | 86400 |
class | IN |
type | SRV |
priority | 10 |
weight | 5 |
port | 5223 |
target | server.example.com |
*Short for "protocol," as in transport protocol.
**Domain name.
However, SRV records are actually formatted in this way:
_service._proto.name. TTL class type of record priority weight port target.
So our example SRV record would actually look like:
_xmpp._tcp.example.com. 86400 IN SRV 10 5 5223 server.example.com.
In the above example, "_xmpp" indicates the type of service (the XMPP protocol) and "_tcp" indicates the TCP transport protocol, while "example.com" is the host, or the domain name. "Server.example.com" is the target server and "5223" indicates the port within that server.
SRV records must point to an A record (in IPv4) or an AAAA record (in IPv6). The server name they list cannot be a CNAME. So "server.example.com" must lead directly to an A or AAAA record under that name.
SRV records indicate the "priority" and "weight" of the various servers they list. The "priority" value in an SRV record enables administrators to prioritize one server that supports the given service over another. A server with a lower priority value will receive more traffic than other servers. However, the "weight" value is similar: a server with a higher weight will receive more traffic than other servers with the same priority.
The main difference between them is that priority is looked at first. If there are three servers, Server A, Server B, and Server C, and they have respective priorities of 10, 20, and 30, then their "weight" does not matter. The service will always query Server A first.
But suppose Servers A, B, and C all have a priority of 10 — how will a service choose between them? This is where weight becomes a factor: if Server A has a "weight" value of 5 and Servers B and C have a "weight" value of 3 and 2, Server A will receive the most traffic, Server B will receive the second-most traffic, and Server C the third-most.