SRV Record
A DNS Service (SRV) record is a specification that defines the location - including the hostname and port number - of servers for specified services. Unlike most DNS records that only provide a server name or IP address, SRV records include both the target server and the specific port where the service is running, along with priority and weight values for load balancing and failover.
How it works
SRV records allow applications to discover services in a domain without requiring manual configuration. They're commonly used for services that need to advertise specific ports, such as VoIP, instant messaging (XMPP), email (SMTP), and directory services (LDAP). By querying SRV records, clients can automatically find the correct server and port for a service.
_service._proto.name
- _service: The symbolic name of the service (e.g., _xmpp, _sip, _ldap)
- _proto: The transport protocol (usually _tcp or _udp)
- name: The domain name
Example: _xmpp._tcp.example.com
**Priority (Lower = Higher Priority):**
Clients should contact servers with the lowest priority value first. If that server is unavailable, they fall back to servers with higher priority values. For example, if you have servers with priorities 10, 20, and 30, the server with priority 10 is always tried first, regardless of weight values.
**Weight (Load Balancing):**
When multiple servers have the same priority, weight determines the proportion of traffic each should receive. Weights are relative values - if three servers with equal priority have weights of 60, 30, and 10 (totaling 100), they'll receive approximately 60%, 30%, and 10% of requests respectively.
**Port:**
The TCP or UDP port number where the service is running on the target server. This is what makes SRV records unique - they specify both the host and the exact port.
**Target:**
The hostname of the server providing the service. This must be an A or AAAA record (not a CNAME).Key Points
- SRV records include both hostname and port number, unlike other DNS records
- Format is
_service._proto.name(e.g.,_xmpp._tcp.example.com) - Priority determines order of contact (lower numbers first), weight determines load distribution among equal priorities
- Commonly used for VoIP, instant messaging, email, and directory services
- The target must point to a hostname with an A or AAAA record, not a CNAME
Common Use Cases
- VoIP and SIP Services: SIP (Session Initiation Protocol) uses SRV records to locate VoIP servers, allowing clients to discover the correct server and port for voice calls automatically
- Instant Messaging (XMPP/Jabber): XMPP services use SRV records to enable federated messaging, allowing servers to discover and connect to other XMPP servers
- Microsoft Active Directory: Active Directory uses SRV records extensively for service discovery, allowing clients to find domain controllers, LDAP servers, and Kerberos services
- Email Submission: The
_submission._tcpSRV record can specify the mail submission service port, complementing MX records for email configuration
code Example SRV Record Configuration
| Type | Host / Name | Value / Points to | TTL |
|---|---|---|---|
| SRV | _xmpp._tcp | 10 60 5222 server1.example.com | 3600 |
| SRV | _xmpp._tcp | 10 40 5222 server2.example.com | 3600 |
| SRV | _xmpp._tcp | 20 0 5222 backup.example.com | 3600 |
| SRV | _sip._tcp | 10 0 5060 voip.example.com | 3600 |
* SRV records specify service, protocol, priority, weight, port, and target. Lower priority = higher preference.
Frequently Asked Questions
What is the difference between priority and weight in SRV records?expand_more
Why can't the target be a CNAME?expand_more
Do I need SRV records for my website?expand_more
How do applications know to look for SRV records?expand_more
_xmpp-client._tcp.example.com SRV records to find the messaging server. The application knows the service name and protocol to look for based on its function. Not all applications support SRV records - support must be explicitly built into the software.