SRV records order retrieved from a DNS server

2.1k views Asked by At

I have to make a DNS lookup for SRV records in Android application and choose the select one of them. When I query a DNS server for multiple SRV records differ in priority and weight, I get the records in different order on each request, are these records ordered by the server? if yes what is the order algorithm?

I guessed it respects the priority as the lower priority is most preferred, but in case the priority is equal I supposed it will respect the weight in a round-robin style, which did not happen!

I had a simple bind9 DNS server with 2 SRV records as follow:


Domain Priority Weight


aaa.example.com 1 90


bbb.example.com 2 10

When I lookup, I expected to get the aaa.example.com 9 times as first result and the 10th I would get bbb.example.com as first result, which did not happen!, the server just reverse the order on each request!

2

There are 2 answers

0
rnbrady On BEST ANSWER

If you are querying for SRV records, the order in which they are returned is arbitrary and should not not be taken into account by your client application.

Rather, your application is responsible for ordering the received results according to weight and priority, as specified in RFC 2782.

Also specified in the RFC is that if multiple records are returned with equal weights and priorities, the client would select randomly, and not according to the order in which those records are returned.

As a result, the use of round-robin DNS to serve SRV records is redundant.

0
sipsorcery On

Since I believe you are asking in the context of a SIP application there are guidelines that should be used to decide which SRV record to use, see http://www.ietf.org/rfc/rfc3263.txt.