toolhq.io

All posts
4 min readby Jameel Haider

SRV records explained

An A record tells you the address of a host, but it says nothing about which port a service listens on or how to balance across several servers. SRV records fill that gap. They let a client discover not just where a service lives but how to prefer one instance over another, all from DNS.

The record format

An SRV record has a structured name and a four-part value:

_sip._tcp.example.com. 3600 IN SRV 10 60 5060 sipserver.example.com.

The name encodes the service and protocol as _service._proto.name, each prefixed with an underscore to avoid clashing with real hostnames. The value, read left to right, is:

  • priority (10): lower numbers are tried first.
  • weight (60): used to share load among records of equal priority.
  • port (5060): the port the service listens on.
  • target (sipserver.example.com.): the actual host, which then needs its own A or AAAA record.

A single dot as the target means the service is explicitly not offered.

How priority and weight select a target

Selection happens in two stages. First the client groups records by priority and uses the lowest-numbered group that has reachable hosts. Priority is how you express a primary and a backup: put your main servers at priority 10 and your failover at priority 20, and clients only fall back when the primaries are down.

Within one priority group, weight distributes load proportionally. Two records at priority 10 with weights 70 and 30 should receive roughly 70 and 30 percent of connections. A weight of 0 means use this host only when no positive-weight host is available.

_sip._tcp.example.com. IN SRV 10 70 5060 sip1.example.com.
_sip._tcp.example.com. IN SRV 10 30 5060 sip2.example.com.
_sip._tcp.example.com. IN SRV 20  0 5060 backup.example.com.

Where they are used

SRV records are the discovery mechanism for several protocols:

  • SIP uses _sip._tcp and _sip._udp to find voice servers.
  • XMPP uses _xmpp-client._tcp and _xmpp-server._tcp for chat.
  • Minecraft Java servers use _minecraft._tcp, which is why a server can run on a nonstandard port while players connect using only the domain name.
  • Microsoft autodiscover and LDAP use SRV to locate mail and directory services.

The common thread is that the client knows the service name but should not hardcode the host or port. DNS supplies both and can change them without touching any client.

Look one up

You can inspect any domain's SRV records with the DNS lookup tool, which queries public resolvers over HTTPS and shows the parsed priority, weight, port, and target. The lookup runs from your browser through a privacy-respecting resolver rather than our servers. For the broader set of record types, see DNS records explained, and how to check MX records for the mail equivalent.

The takeaway: when a service needs to advertise both a host and a port, and wants failover and load sharing for free, SRV records do it in DNS so clients stay simple.