DNS SRV Record: How Clients Find a Service
A client configured with a fixed server name must be updated when that server moves. A client that supports service discovery can instead ask DNS where the service is offered and which port to use. An SRV record in DNS supplies that information, but only when the application is designed and configured to consult it.
A DNS SRV record maps a service and protocol within a domain to one or more target hosts and ports. The client still has work to do: select a target, resolve its address, connect, and verify the service according to the application’s own rules. Publishing a record does not make an arbitrary application use it.
Read the service name and fields
An SRV owner name has the form _service._protocol.domain. The service label identifies the application service, and the protocol label identifies the transport, commonly _tcp or _udp. The leading underscores distinguish these labels from ordinary host names. The domain identifies the administrative namespace in which the service is being sought.
Consider this fictional example for an XMPP client service:
_xmpp-client._tcp.example.com. 300 IN SRV 10 60 5222 chat1.example.com.
_xmpp-client._tcp.example.com. 300 IN SRV 10 40 5222 chat2.example.com.
_xmpp-client._tcp.example.com. 300 IN SRV 20 0 5222 backup.example.com.
The values after SRV are priority, weight, port, and target. A lower priority number is preferred. The first two targets share priority 10, so a supporting client uses their relative weights when ordering choices within that group. The target at priority 20 is considered if the preferred group cannot be used, following the application’s rules. Weight influences selection probability; it is not a real-time measurement of server load or a guarantee of an exact traffic split.
The port indicates where the service listens on the chosen target. The target is a host name, not an IP address; the client obtains suitable address records for that host before connecting. RFC 2782, published in 2000, defines these fields and requires a target name with address records rather than an alias. The example names are reserved for documentation and do not describe a live service.
Follow a supporting client
For a user in the example domain, a compliant XMPP client can look up _xmpp-client._tcp.example.com, order the returned targets, resolve the selected host, and attempt a TCP connection to the advertised port. RFC 6120, published in 2011, describes this discovery process for XMPP. The client then performs the application’s connection and security checks; a DNS answer alone does not authenticate the service or prove it is healthy.
Records can exist for several services under the same domain. A DNS service record for SRV discovery is specific to its service and transport labels. An application that uses a configured host directly, or a different discovery method, may never query that name. A target of . has special meaning in SRV: it indicates that the service is not available at that domain; it is not a normal host to contact.
Maintain records and diagnose results
Keep DNS records for SRV services, target names, addresses, ports, and service configuration aligned with the actual deployment. A published SRV entry in DNS can point to a host that no longer listens or is blocked by network policy. TTL controls ordinary cache lifetime, so a recent change may not be visible immediately to every resolver. Also check whether the client is using the expected internal or external DNS view.
For an authorized check, first inspect the authoritative SRV answer for the exact service name and compare priority, weight, port, and target with the intended design. Resolve each target’s address and verify that the service is listening and reachable on its advertised port. Then observe a supporting client’s lookup and connection, including its handling of an unavailable target. Compare the client’s resolver and cached data with the authoritative answer before changing the DNS SRV record. Document the result so that future changes to SRV records in DNS can be tested against the same service path.