SRV: service location
*Find the host and* port for a named service.** SRV records let a client discover where a service like
_xmpp-server._tcp.example.comlives, without hard-coding a hostname or port.
In one line:
_xmpp-server._tcp.example.com. SRV 10 5 5269 xmpp.example.com.
└── service.protocol.domain ──┘ └type┘ └── priority weight PORT target| Type number | 33 |
| RFC | 2782 |
| RDATA | priority · weight · port · target FQDN |
What it holds#
| Field | Purpose |
|---|---|
| Priority | Lower wins: clients try the record with the lowest priority value first, which is the highest priority. (Same idea as MX preference.) |
| Weight | Within one priority level, weighted random distribution. Higher weight = more traffic. |
| Port | TCP/UDP port the service listens on. |
| Target | A hostname (A/AAAA: NOT a CNAME, the same rule as MX). |
_ldap._tcp.example.com. SRV 10 0 389 ldap.example.com.
_kerberos._udp.example.com. SRV 0 0 88 kdc.example.com.When to use it#
- Whenever the service has a registered SRV form: XMPP, SIP, LDAP, Kerberos, autodiscover, Matrix federation.
- For service discovery without a load balancer: clients query SRV and get a weighted list of backends.
- For in-house services where you want the name decoupled from a fixed hostname and port.
When not to use it#
- For HTTP/HTTPS: those use HTTPS/SVCB instead. Browsers do not query SRV for web traffic.
- For a service with no client support for SRV: a record nothing reads is dead weight.
dig example#
Asks where the XMPP server for example.isitdns.net lives.
dig @1.1.1.1 _xmpp-server._tcp.example.isitdns.net SRVGO NOERROR and one SRV with priority, weight, port and target
NO GO NOERROR with no answer, which means the service is not published here
RFC: RFC 2782 defines the _service._proto.name form, the four RDATA fields, and the priority-then-weight selection algorithm clients run over the answer.
DoH query (HTTPS)#
DoH is DNS-over-HTTPS (RFC 8484); the JSON form below is a Cloudflare/Google extension, not part of the RFC itself:
curl -s -H 'accept: application/dns-json' \
'https://cloudflare-dns.com/dns-query?name=_xmpp-server._tcp.example.isitdns.net&type=SRV' \
| jq .Answer[
{
"name": "_xmpp-server._tcp.example.isitdns.net",
"type": 33,
"TTL": 300,
"data": "10 5 5269 example.com"
}
]"AD": true in the full response (not shown by jq .Answer) means the resolver validated the DNSSEC chain for this answer (RFC 4035 §3.2.3).
Gotchas#
- Target must not be an alias. RFC 2782 requires the target to have its own address record and forbids it being an alias, so it cannot be a CNAME.
- Service and proto labels start with underscore.
_ldap, notldap._tcp, nottcp. Miss it and discovery silently fails. - A target of
.means no service. RFC 2782 defines a target of.(the root) as "the service is decidedly not available at this domain," the SRV equivalent of null MX. - Weight 0 is the documented way to say "no preference." RFC 2782 recommends weight 0 when there is nothing to load-balance; among records with weight greater than 0, a weight-0 record still gets only a small chance of being picked.
- DANE over SRV is protocol-specific. RFC 7673 lets protocols that use SRV hang a TLSA record off the SRV target (its examples are IMAP and XMPP). SMTP does not use SRV, so its DANE profile (RFC 7672) hangs off the MX target instead. The
_xmpp-server._tcp.example.isitdns.netdemo record above is signed and validates.
See also#
- TLSA/DANE: certificate binding, paired with SRV for XMPP (RFC 7673) and with MX for SMTP (RFC 7672)
- All record types: cheat sheet
- nslookup and dig: command reference for the queries on this page
- Query types: how ANY, SRV, and other qtype requests work