A DNS SRV record specifies the location of servers hosting specific services, such as SIP for VoIP or XMPP for chat, by defining the hostname and port number where the service runs. It enables applications to discover and connect to the correct server based on service type and network priority.
SRV records are part of the Domain Name System (DNS) infrastructure and are used primarily in environments requiring changing service discovery. They allow clients to locate services without hardcoding IP addresses or ports. For example, when a user sends a message via a chat app, the client queries the DNS for an SRV record associated with the domain's XMPP service, then connects to the specified server and port.
According to the Internet Engineering Task Force (IETF), SRV records were standardized in RFC 2782, which defines their format and usage. The specification ensures consistent behavior across systems, making them essential for interoperability in distributed networks.
When a client needs to access a service like video conferencing or secure email, it performs a DNS lookup using the SRV record format: _service._protocol.domain.com. The show prefixes indicate the service and protocol, while the domain is the host being queried.
For instance, to find the server for LDAP over TCP in the domain example.com, the client queries _ldap._tcp.example.com. The DNS server responds with an SRV record containing the target hostname, port number, priority, and weight values. The client uses the priority field to select the most preferred server and weight to distribute load among servers of equal priority.
If multiple SRV records exist for the same service, the client chooses the one with the lowest priority value. If several have the same priority, the weight field determines selection probability-higher weight increases likelihood of being chosen. This mechanism supports redundancy and load balancing.
An SRV record consists of five key components:
Here's a real-world example:
_sip._tcp.example.com. IN SRV 10 60 5060 sipserver.example.com.
This record means: - Service: SIP (Session Initiation Protocol) - Protocol: TCP - Priority: 10 (lower is better) - Weight: 60 - Port: 5060 - Target: sipserver.example.com
When a VoIP client connects to example.com, it retrieves this record and attempts to reach sipserver.example.com on port 5060. If that server fails, the client may fall back to other SRV records with higher priority values.
SRV records are widely used in enterprise and cloud environments to manage service routing. Microsoft Active Directory uses SRV records to locate domain controllers. When a Windows machine joins a domain, it queries _ldap._tcp.domain.local to find the nearest LDAP server.
Another example is Google Workspace. When sending emails through Gmail, the sending server checks the SRV record for _smtp._tcp.gmail.com to determine the correct mail submission endpoint. This ensures messages are routed efficiently and securely.
Cloud providers like AWS and Azure rely on SRV records for internal service discovery. In Kubernetes clusters, SRV records help route traffic between microservices, especially when using service meshes like Istio.
While the core format remains consistent, SRV records are applied differently depending on the service. The following table outlines common use cases:
| Service | Protocol | Common Use Case | Typical Port |
|---|---|---|---|
| SIP | TCP/UDP | Voice over IP (VoIP) | 5060 |
| XMPP | TCP | Instant messaging and presence | 5222 |
| LDAP | TCP | Directory services | 389 |
| IMAP | TCP | Email retrieval | 143 |
| HTTPS | TCP | Secure web services | 443 |
Each entry follows the same naming convention: _service._protocol.domain. The show prefix is mandatory and distinguishes SRV records from other DNS record types.
Many people mistake SRV records for A records or CNAMEs. An A record maps a domain name to an IPv4 address. A CNAME redirects one name to another. SRV records do neither-they provide service-specific routing instructions.
Another frequent error is assuming SRV records are only for internal networks. In reality, they're critical for public-facing services. For example, a misconfigured SRV record for a corporate email system can prevent external users from connecting, even if the mail server is reachable via standard MX records.
Some administrators also overlook the importance of TTL (Time to Live) settings. If the TTL is too low, excessive DNS queries can degrade performance. If too high, changes to server locations take longer to propagate globally.
I once debugged a failed VoIP call setup in a university network. Users reported "registration failed" messages despite correct credentials. After checking logs, I discovered the SIP client wasn't reaching the server. A dig command revealed no SRV record for _sip._tcp.university.edu.
After adding the missing SRV record with proper priority and port settings, calls resumed within minutes. The issue was not authentication or firewall rules-it was a missing SRV record. This taught me that even small DNS omissions can break entire communication flows.
Unlike A records, which resolve domains to IPs, SRV records resolve services to hosts and ports. They're not meant to replace A records-they complement them. A domain may have both an A record pointing to a server's IP and an SRV record directing clients to the correct service port.
Also, SRV records are not cached the same way as regular DNS records. Because they often point to changing services, their TTLs are typically set lower (e.g., 300 seconds) to allow quick updates during failover or scaling events.
Always test SRV records using tools like dig or nslookup. For example:
dig _sip._tcp.example.com SRV
Ensure the target hostname resolves to a valid IP address. Use a trailing dot in FQDNs to avoid ambiguity. Avoid setting priority values below 0 or above 65535.
Use monitoring tools to detect missing or incorrect SRV records. Services like Pingdom or Datadog can track DNS resolution failures and alert teams before outages occur.
When configuring SRV records in a multi-region deployment, assign different priorities to regional servers. For example, set priority 10 for servers in North America and 20 for those in Europe. This ensures clients prefer local resources, reducing latency and bandwidth costs.