DNS SRV Record
Service Locator RecordWhat is a SRV Record?
A DNS SRV record (Service record) specifies the hostname and port number for a specific service on a domain. Unlike other DNS records that only provide hostname or IP information, SRV records include additional metadata: priority, weight, port number, and target hostname. This allows clients to discover services dynamically without hardcoding connection details.
SRV records follow a specific naming convention: _service._protocol.domain. For example, _sip._tcp.example.com specifies a SIP service over TCP. The priority and weight fields work similarly to MX records — priority determines the order of preference (lower = preferred), while weight provides load balancing among servers with the same priority. A higher weight means the server receives proportionally more traffic.
SRV records are widely used by protocols like SIP (VoIP), XMPP (instant messaging), LDAP (directory services), and Microsoft Active Directory. Kubernetes also uses SRV records for service discovery within clusters. However, HTTP/HTTPS do not natively support SRV record lookups, which limits their use for standard web browsing.
Syntax & Examples
The syntax of a DNS SRV record includes priority, weight, port, and target:
_sip._tcp.example.com. 3600 IN SRV 10 60 5060 sipserver1.example.com.
_sip._tcp.example.com. 3600 IN SRV 10 40 5060 sipserver2.example.com.
_sip._tcp.example.com. 3600 IN SRV 20 0 5060 sipbackup.example.com.
The format is: _service._protocol.domain TTL class SRV priority weight port target. In this example, sipserver1 (weight 60) and sipserver2 (weight 40) share priority 10, receiving 60% and 40% of traffic respectively. sipbackup at priority 20 is only used if both primary servers fail. A target of '.' means the service is explicitly not available.
How to Query SRV Records
To query SRV records using dig, run: dig _sip._tcp.example.com SRV. For concise output: dig +short _sip._tcp.example.com SRV. The output shows priority, weight, port, and target for each service endpoint. Common SRV queries include: dig _xmpp-server._tcp.example.com SRV (XMPP), dig _ldap._tcp.example.com SRV (LDAP), and dig _kerberos._tcp.example.com SRV (Kerberos).
With nslookup, use: nslookup -type=SRV _sip._tcp.example.com. On Windows PowerShell: Resolve-DnsName -Name _sip._tcp.example.com -Type SRV. For Microsoft Active Directory environments, querying _ldap._tcp.dc._msdcs.domain.com reveals domain controller locations. Remember that SRV records use the _service._protocol prefix naming convention.
Related Record Types
Frequently Asked Questions
What is a DNS SRV record?
A DNS SRV (Service) record defines the location of a specific service by specifying its hostname, port number, priority, and weight. It follows the naming format _service._protocol.domain and is used by protocols like SIP, XMPP, and LDAP for automatic service discovery.
How do SRV priority and weight work?
Priority determines which server to try first (lower value = higher priority). Weight provides load balancing among servers with the same priority — a server with weight 60 gets roughly 60% of traffic compared to one with weight 40 getting 40%. A weight of 0 means the server should only be used if no other servers of the same priority are available.
Does HTTP/HTTPS support SRV records?
Standard web browsers do not natively look up SRV records for HTTP/HTTPS connections. Some applications and libraries support SRV lookups for HTTP, and proposals exist to add SRV support via HTTPSSVC/SVCB records (RFC 9460). For now, web services typically use A/AAAA records or CNAME records.
What services commonly use SRV records?
Common services using SRV records include: SIP (VoIP telephony), XMPP/Jabber (instant messaging), LDAP (directory services), Kerberos (authentication), Microsoft Active Directory, CalDAV/CardDAV (calendar and contacts), and Minecraft (game server discovery). Kubernetes also uses SRV records internally.
How do I disable a service using SRV records?
To explicitly indicate that a service is not available, create an SRV record with the target set to '.' (a single dot). For example: _sip._tcp.example.com. 3600 IN SRV 0 0 0 . — This tells clients that the SIP service is intentionally not provided at this domain.