Order in which Resource Records(RR) are answered by Bind if Order and preference are Same

I had a query on how the following Records can be ordered on how the Records are configured in the Zone file

I have done 2 different Tests

I have configured following records in the Zone file e164enum.net with TTL value as 0

2.7.5.2.7.9.2.5.3.1.8.e164enum.net. IN NAPTR 100 10 "u" "E2U+sip" "!^.*$!sip:7895673454@ATLANTA.COM;user=phone!" .
2.7.5.2.7.9.2.5.3.1.8.e164enum.net. IN NAPTR 100 10 "u" "E2U+sip" "!^.*$!sip:7895673453@ATLANTA.COM;user=phone!" .

Now whenever I run a “dig” query on the bind server for “dig 2.7.5.2.7.9.2.5.3.1.8.e164enum.net. NAPTR”

I receive responses like, toggled in Answer section

First dig query

;; <<>> DiG 9.9.5-rpz2+rl.14038.05-P1 <<>> 2.7.5.2.7.9.2.5.3.1.8.e164enum.net. NAPTR
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 37270
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 1, ADDITIONAL: 2

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;2.7.5.2.7.9.2.5.3.1.8.e164enum.net. IN NAPTR

;; ANSWER SECTION:
2.7.5.2.7.9.2.5.3.1.8.e164enum.net. 0 IN NAPTR  100 10 "u" "E2U+sip" "!^.*$!sip:7895673453@ATLANTA.COM\;user=phone!" .
2.7.5.2.7.9.2.5.3.1.8.e164enum.net. 0 IN NAPTR  100 10 "u" "E2U+sip" "!^.*$!sip:7895673454@ATLANTA.COM\;user=phone!" .

;; AUTHORITY SECTION:
e164enum.net.           0       IN      NS      HP3bl10VM5DNS.e164enum.net.

;; ADDITIONAL SECTION:
HP3bl10VM5DNS.e164enum.net. 0   IN      A       10.54.212.235

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Tue Jul 19 00:31:16 IST 2016
;; MSG SIZE  rcvd: 261

2nd dig query

; <<>> DiG 9.9.5-rpz2+rl.14038.05-P1 <<>> 2.7.5.2.7.9.2.5.3.1.8.e164enum.net. NAPTR
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 40073
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 1, ADDITIONAL: 2

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;2.7.5.2.7.9.2.5.3.1.8.e164enum.net. IN NAPTR

;; ANSWER SECTION:
2.7.5.2.7.9.2.5.3.1.8.e164enum.net. 0 IN NAPTR  100 10 "u" "E2U+sip" "!^.*$!sip:7895673454@ATLANTA.COM\;user=phone!" .
2.7.5.2.7.9.2.5.3.1.8.e164enum.net. 0 IN NAPTR  100 10 "u" "E2U+sip" "!^.*$!sip:7895673453@ATLANTA.COM\;user=phone!" .

;; AUTHORITY SECTION:
e164enum.net.           0       IN      NS      HP3bl10VM5DNS.e164enum.net.

;; ADDITIONAL SECTION:
HP3bl10VM5DNS.e164enum.net. 0   IN      A       10.54.212.235

;; Query time: 1 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Tue Jul 19 00:31:19 IST 2016
;; MSG SIZE  rcvd: 261

As I see, the responses (RR Answers) from bind server toggle for each dig

Since I did not want the Answers to be toggled in each susbsequent digs, and I wanted the Answers to be in the same Order they were configured in the Zone file(since the Order and Preference of both these records were same), I enabled this line in the options field of named.conf

rrset-order {order fixed;};

and restarted named

I ran the dig query again
This time, the Answers did not toggle, but I found that, the second configured RR was being Answered as first always
This record was always being answered first inspite of being second in my configured preference(assuming that configuring rrset-order will always return RR Answers in the same order as configured in the Zone file)

Query#1

; <<>> DiG 9.9.5-rpz2+rl.14038.05-P1 <<>> 2.7.5.2.7.9.2.5.3.1.8.e164enum.net. NAPTR
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 18221
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 1, ADDITIONAL: 2

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;2.7.5.2.7.9.2.5.3.1.8.e164enum.net. IN NAPTR

;; ANSWER SECTION:
2.7.5.2.7.9.2.5.3.1.8.e164enum.net. 0 IN NAPTR  100 10 "u" "E2U+sip" "!^.*$!sip:7895673453@ATLANTA.COM\;user=phone!" .
2.7.5.2.7.9.2.5.3.1.8.e164enum.net. 0 IN NAPTR  100 10 "u" "E2U+sip" "!^.*$!sip:7895673454@ATLANTA.COM\;user=phone!" .

;; AUTHORITY SECTION:
e164enum.net.           0       IN      NS      HP3bl10VM5DNS.e164enum.net.

;; ADDITIONAL SECTION:
HP3bl10VM5DNS.e164enum.net. 0   IN      A       10.54.212.235

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Tue Jul 19 00:36:30 IST 2016
;; MSG SIZE  rcvd: 261

Query#2

; <<>> DiG 9.9.5-rpz2+rl.14038.05-P1 <<>> 2.7.5.2.7.9.2.5.3.1.8.e164enum.net. NAPTR
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 17082
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 1, ADDITIONAL: 2

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;2.7.5.2.7.9.2.5.3.1.8.e164enum.net. IN NAPTR

;; ANSWER SECTION:
2.7.5.2.7.9.2.5.3.1.8.e164enum.net. 0 IN NAPTR  100 10 "u" "E2U+sip" "!^.*$!sip:7895673453@ATLANTA.COM\;user=phone!" .
2.7.5.2.7.9.2.5.3.1.8.e164enum.net. 0 IN NAPTR  100 10 "u" "E2U+sip" "!^.*$!sip:7895673454@ATLANTA.COM\;user=phone!" .

;; AUTHORITY SECTION:
e164enum.net.           0       IN      NS      HP3bl10VM5DNS.e164enum.net.

;; ADDITIONAL SECTION:
HP3bl10VM5DNS.e164enum.net. 0   IN      A       10.54.212.235

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Tue Jul 19 00:36:33 IST 2016
;; MSG SIZE  rcvd: 261

Why is Bind answering the Second RR as first and not my original First RR as 1st Answer?

Answer

The bind documentation says (for my bind version 9.9.5) :

In this release of BIND 9, the rrset-order statement does not support “fixed” ordering by default. Fixed ordering can be enabled at compile time by specifying “–enable-fixed-rrset” on
the “configure” command line.

So maybe the problem is in your bind version. You did not specify which one you are using, maybe you should try with another version?

Attribution
Source : Link , Question Author : Harshith Mulky , Answer Author : Patrick Mevzek

Leave a Comment