What is SRV Record and Why You Might Need One

There exist quite a few DNS record types. One of the least known is SRV record. Here we’ll explain the nature of it and describe a few use cases.

Services Resource Record (SRV) allows a service to be associated with a hostname. Any application that needs to discover where a specific service is located will initiate a query for the relevant SRV record describing the service.

The above mentioned query will return the following data:

  • one or more host name(s)
  • port the service is working on
  • two values used to determine the relative priority and performance of the service

Having obtained the hostname, the A or AAAA record, the query will also obtain relevant IP addresses.

SRV records are supported and used by the variety of services as LDAP, SIP, MS Outlook, XMPP etc.

Common syntax of a SRV record

Service

Protocol

Priority

Weight

Port

Host

Target

TTL

_sip

TCP / UDP / TLS

0

1

2000

[optional]

www.sip.domain.com.

15min/1hour/1day/1week

 

Where each field means the following:

Service – defines the symbolic service name. These always begin with underscore symbol. List of standard services is maintained by IANA: http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xml

Protocol – defines protocol name, common values are _tcp and _udp.

Priority – lower numbers mean higher priority in the range of 0-65535.

Weight – used when more than one service is listed with the same priority. If you have two SRV records with 0 (zero) priority but one of them has weight of 1 and the other has weight of 4 – the record with weight 4 will be delivered 4 times out of 5 by nameservers. The range of weight values is 0-65535.

Port – defines port number that delivers the service on target server. You can use, for example, port 2000 instead of more common port 80.

Host – defines the external domain for the target.

Target – defines the name of the host that will provide the service and requires a proper A or AAAA record. If the ‘Host’ entry is omitted the target is considered as internal. A value of ‘.’ on the target blocks a service on your host.

TTL – time-to-live value which defines how long the caching nameservers should cache your SRV record before querying your DNS server for the new value again.

Examples

1. Defines LDAP service available at ldap.domain.com:

A (Host record)

ldap   192.168.1.66   1Day

SRV (Service record)

_ldap   TCP   0   5   389   ldap   1Week

2. Simple load balancing. The .51 server will get 2 times more connections than .50:

A (Host records)

www   192.168.1.51   1Day
192.168.1.50   1Day
backup   192.168.1.55   1Day

SRV (Service record)

_http   TCP   0   2   80   www.domain.com.   1Week
_http   TCP   0   1   80   www2.domain.com.   1Week
_http   TCP   1   1   2000   backup.domain.com.   1Week

If a client does not ‘understand’ SRV records, it will be using Round-Robin switching listed in A records. If both .50 and .51 servers aren’t accessible – backup.domain.com server (.55) will be used.


Was this article helpful?
Spread the word!