SRV records order retrieved from a DNS server

牧云@^-^@ 提交于 2019-12-23 03:04:56

问题


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!


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/8957145/srv-records-order-retrieved-from-a-dns-server

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!