The SRV record type was proposed in the late 1990s in RFC 2782. The SRV record addresses limitations in the DNS around advertising and consuming services. Not all application protocols support SRV, but many do.

Each SRV record specifies one possible endpoint for a service. Each record also includes information on how clients should select among the available endpoints. The owner name of the SRV record is an essential part of the format. Like all other records in the DNS, each SRV record also has a Time-to-Live (TTL) value in seconds.
The SRV record format is:
_Service._Proto.Name TTL SRV Priority Weight Port Target
Let's examine each of the SRV record fields one by one.
Priority and weight determine how clients select one of the endpoints in a set of SRV records. Priority is similar to the preference field in MX records. But SRV also includes a random component through the weight field for more dynamic load balancing.
The endpoints with the lowest priority are used first. Weight specifies the relative amount of requests that each endpoint with the same priority should receive.
Clients randomly select one of the endpoints using their weights if multiple SRV records have the same priority. The client adds the weight values and generates a random number between 1 and the sum of the weights to select an endpoint.
If two SRV records have the same priority value and weight values of 100 and 900, a client would generate a random number between 1 and 1000. If the result is 1 through 100, the first endpoint would be used. If the result is 101 through 1000, the second endpoint would be used. The same load balancing would be achieved if the weight values were 10 and 90 because weights are relative.
The same value can be used for all weights if the service owner wants equal load balancing. A value of 1 is typical in this case.
Many applications have used SRV records over the years. Service names were first collected in a temporary registry operated by dns-sd.org. The Internet Assigned Numbers Authority (IANA) now maintains an official registry of service names. The IANA registry includes whether TCP or UDP is supported and a default port number.
To find the set of endpoints for a service that uses SRV records, a client sends a DNS query of type SRV for a query name in the format _Service._Protocol.Name. The application protocol specifies the service and protocol values in the query name. For Minecraft, the first label is "_minecraft" and the second label is "_tcp".
Putting these values together, the query name to discover the example.org Minecraft servers would be _minecraft._tcp.example.org.
The SRV record set for the Minecraft servers for example.org might look like this:
_minecraft._tcp.example.org 3600 SRV 1 100 25565 mserver1.example.org. _minecraft._tcp.example.org 3600 SRV 1 50 25565 mserver2.example.org. _minecraft._tcp.example.org 3600 SRV 2 100 25565 mserver3.example.org.
As we've already seen, the service name is "_minecraft", and the protocol is "_tcp". The TTL for each record is one hour (3600 seconds).
The first two endpoints have a priority of 1. Clients contact these first. The third endpoint has a priority of 2 so clients only use it if the first two servers are down. "mserver3" is a fallback server.
The weight for the first server is 100, and the weight for the second server is 50. Clients randomly select between these two servers such that two-thirds of requests go to "mserver1" and one-third go to "mserver2".
Lastly comes the port and target. The target is the DNS name of the server hosting the endpoint. This example uses the default Minecraft port of 25565. A different port value can be used. The Minecraft server's port configuration must match the port value in the SRV record.
Kubernetes uses SRV records for named ports. A named port is an endpoint for a service. The owner name of the SRV record in the DNS is of the form: _my-port-name._my-port-protocol.my-svc.my-namespace.svc.my-zone.
An example SRV record for a Kubernetes HTTPS endpoint for example.org:
_https._tcp.kubernetes.default.svc.example.org. 3600 SRV 1 100 443 kubernetes.default.svc.example.org.
For more information on how Kubernetes uses the DNS, read our article on the life of a DNS query in Kubernetes.
Many application protocols use SRV records. A few examples:
_sip._udp.example.org 3600 SRV 1 100 5060 sip_server.example.org.
_xmpp-client._tcp.example.org 3600 SRV 1 100 5060 xmpp_server.example.org. _xmpp-server._tcp.example.org 3600 SRV 1 100 5060 xmpp_server.example.org.
_kerberos._udp.example.org 3600 SRV 1 100 88 kdc1.example.org. _kerberos._tcp.example.org 3600 SRV 1 100 88 kdc1.example.org. _kerberos-master._tcp.example.org 3600 SRV 1 100 749 kdcm.example.org. _kpasswd._tcp.example.org 3600 SRV 1 100 464 kdc1.example.org.
_ldap._tcp.example.org 3600 SRV 1 100 389 ldap1.example.org. _ldap._tcp.example.org 3600 SRV 1 100 389 ldap2.example.org.
_caldav._tcp.example.org 3600 SRV 1 100 8008 cal_srv.example.org. _caldavs._tcp.example.org 3600 SRV 1 100 8443 cal_secure_srv.example.org. _carddav._tcp.example.org 3600 SRV 1 100 8008 card_srv.example.org. _carddavs._tcp.example.org 3600 SRV 1 100 8443 card_secure_srv.example.org.
_matrix._tcp.example.org 3600 SRV 1 100 8448 matrix_server.example.org.
Before SRV, the only way to advertise a service was to publish a set of address records for a name. There was no way to provide a port number or order the endpoints.
Several other DNS record types exist for service location. These include:
The dig or nslookup command line tools can query SRV records for a DNS name. To find the LDAP SRV records for Google, use this command:
dig SRV _ldap._tcp.google.com
On operating systems that support nslookup, you can use the following:
nslookup -type=srv _ldap._tcp.google.com
You can also check the SRV records for any domain name in our SRV lookup tool or by entering it here: