Open EchoStone1101 opened 6 months ago
After looking into how bind9 handles this case, I realize that there is one more complication.
Quoting RFC9499 section 4 on referrals:
In the case where the query matches an alias, and the server is not authoritative for the target of the alias but is authoritative for some name above the target of the alias, the resolution algorithm will produce a response that contains both the authoritative answer for the alias and a referral. Such a partial answer and referral response has data in the Answer section. It has the NS RRset for the referred-to zone in the Authority section. It may contain RRs that provide addresses in the Additional section. The AA bit is set because the first name in the Answer section matches the QNAME and the server is authoritative for that answer (see [RFC1035], Section 4.1.1).
And the RFC1035 part mentioned:
AA Authoritative Answer - this bit is valid in responses, and specifies that the responding name server is an authority for the domain name in question section. Note that the contents of the answer section may have multiple owner names because of aliases. The AA bit corresponds to the name which matches the query name, or the first owner name in the answer section.
So in this case, the AA bit should be set, and it corresponds to the g.a.b. DNAME
record in the ANSWER section (I was initially surprised to see bind9 has AA set and assumed it was a bug as well..).
Anyhow, CoreDNS may be correct to have set AA, but returning zone cut NS records in the answer section is still wrong.
What happened:
When the
file
plugin chases a DNAME chain and ends up at a zonecut, the response has AA set (despite being a referral), and uses the apex NS records of the current zone as AUTHORITY, not the NS records at the zonecut. Further, if the query is forNS
, the zonecut NS records is included in the ANSWER section.How to reproduce it (as minimally and precisely as possible):
Using the following zone file (
a.b.txt
):and this Corefile:
Response for querying
<h.g.a.b., A>
(output beautified):What you expected to happen:
aa
should not be set (querying<h.a.b., A>
directly, theaa
bit is indeed not set), and the AUTHORITY section should include theh.a.b. NS
record.Further, if instead the query is for
NS
:The
h.a.b. NS
record is in the ANSWER section, which is incorrect. Querying forh.a.b. NS
directly would still end up with a referral response, where the ANSWER section is empty.(Judging from these responses, it seems that CoreDNS is just not treating the response as a referral.)
Anything else we need to know?:
Environment:
CoreDNS-1.11.1, linux/arm64, go1.21.5, 45923b6e
Bind9 behavior under the same setup: the AUTHORITY is
h.a.b. NS
, and the ANSWER section never contains theNS
record.