Skip to content

fix: return SOA and NS records when queried for a record CNAMEd to origin#7808

Merged
yongtang merged 2 commits into
coredns:masterfrom
shiv-tyagi:fix-cname
Jan 22, 2026
Merged

fix: return SOA and NS records when queried for a record CNAMEd to origin#7808
yongtang merged 2 commits into
coredns:masterfrom
shiv-tyagi:fix-cname

Conversation

@shiv-tyagi

@shiv-tyagi shiv-tyagi commented Jan 11, 2026

Copy link
Copy Markdown
Contributor

1. Why is this pull request needed and what does it do?

This fixes the file plugin to return answer to an NS/SOA query for a record which is CNAMEd to zone origin. This brings it inline with standard bind9 behaviour.

The problem was that we were ignoring SOA and NS records while looking up for the CNAME target (since those records are not stored in the zone tree). A simple fix is to propagate the query to upstream with target name and query type, which would return the answer correctly (as the upstream search still begins with current plugin and returns answer to NS/SOA records).

2. Which issues (if any) are related?

Fixes #6630

3. Which documentation changes (if any) need to be made?

NA

4. Does this introduce a backward incompatible change or deprecation?

NA

…igin

Signed-off-by: Shiv Tyagi <shivtyagi3015@gmail.com>
@shiv-tyagi

Copy link
Copy Markdown
Contributor Author

I have tested this locally.

Using the following zone file (b.a.txt):

b.a.		500 IN SOA	mname.com. rname.com. 3 604800 86400 2419200 604800
b.a.		500 IN NS	h.b.a.
b.a.        500 IN A    1.1.1.1
d.b.a.		500 IN CNAME	b.a.
h.b.a.		500 IN A	100.235.151.110

and this Corefile:

b.a.:1053 {
    header {
        response set ra
    }
    file b.a.txt
}

Here are the results:-

  1. On master
Screenshot from 2026-01-11 14-40-58
  1. On this branch
Screenshot from 2026-01-11 14-36-55

@shiv-tyagi

Copy link
Copy Markdown
Contributor Author

@yongtang Can you please look into this?

@yongtang

Copy link
Copy Markdown
Member

@shiv-tyagi Would you mind to write a test for it?

@shiv-tyagi

Copy link
Copy Markdown
Contributor Author

Sure @yongtang. I have added a test. Please check. Thanks for looking at this.

…lugin

Signed-off-by: Shiv Tyagi <shivtyagi3015@gmail.com>
@shiv-tyagi

Copy link
Copy Markdown
Contributor Author

@yongtang Is there anything else blocking this PR? PTAL and let me know, I will be happy to do additional changes whatever required.

@yongtang yongtang merged commit f1f0955 into coredns:master Jan 22, 2026
11 checks passed
yongtang pushed a commit to yongtang/coredns that referenced this pull request Mar 18, 2026
…igin (coredns#7808)

* fix: return SOA and NS records when queried for a record CNAMEd to origin

Signed-off-by: Shiv Tyagi <shivtyagi3015@gmail.com>

* chore(test): add test for covering cname to origin scenario in file plugin

Signed-off-by: Shiv Tyagi <shivtyagi3015@gmail.com>

---------

Signed-off-by: Shiv Tyagi <shivtyagi3015@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Apex SOA/NS not included in answers after CNAME aliasing

2 participants