[PR #2379] [MERGED] Forwarder: fix NXDOMAIN status code and allow it to forward SOA records #2999

Closed
opened 2026-03-16 11:19:35 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hickory-dns/hickory-dns/pull/2379
Author: @hch12907
Created: 8/23/2024
Status: Merged
Merged: 9/2/2024
Merged by: @djc

Base: mainHead: main


📝 Commits (2)

  • 49a3979 Plumb is_no_records_found() and into_soa() across all error types
  • a28dbac Forward SOA records in NXDOMAIN

📊 Changes

5 files changed (+155 additions, -20 deletions)

View changed files

📝 crates/proto/src/error.rs (+27 -0)
📝 crates/recursor/src/error.rs (+28 -0)
📝 crates/resolver/src/error.rs (+23 -0)
📝 crates/server/src/authority/catalog.rs (+46 -19)
📝 crates/server/src/authority/error.rs (+31 -1)

📄 Description

Currently, the forwarder handles both NXDOMAIN and SOA forwarding rather poorly. The is_nx_domain() check is incomplete & did not consider NXDOMAIN in ResolveErrors and RecursiveErrors. SOA records were outright ignored.

This PR fixes those issues. Here's the result from dig when a nonexistent domain is queried:

; <<>> DiG 9.20.1 <<>> @127.0.0.1 -p 8553 nothing.example.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 19646
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags: do; udp: 1232
;; QUESTION SECTION:
;nothing.example.com.           IN      A

;; AUTHORITY SECTION:
example.com.            1800    IN      SOA     ns.icann.org. noc.dns.icann.org. 2024081402 7200 3600 1209600 3600

;; Query time: 203 msec
;; SERVER: 127.0.0.1#8553(127.0.0.1) (UDP)
;; WHEN: Fri Aug 23 21:53:56 +08 2024
;; MSG SIZE  rcvd: 115

Compared to the result before:

; <<>> DiG 9.20.1 <<>> @127.0.0.1 -p 8553 nothing.example.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 41628
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags: do; udp: 1232
; OPT=5: 08 0d 0e 0f ("....")
; OPT=6: 08 0d 0e 0f ("....")
;; QUESTION SECTION:
;nothing.example.com.           IN      A

;; Query time: 420 msec
;; SERVER: 127.0.0.1#8553(127.0.0.1) (UDP)
;; WHEN: Fri Aug 23 22:08:33 +08 2024
;; MSG SIZE  rcvd: 64

This closes #1891.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hickory-dns/hickory-dns/pull/2379 **Author:** [@hch12907](https://github.com/hch12907) **Created:** 8/23/2024 **Status:** ✅ Merged **Merged:** 9/2/2024 **Merged by:** [@djc](https://github.com/djc) **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (2) - [`49a3979`](https://github.com/hickory-dns/hickory-dns/commit/49a39791b2598d031673e8a8af37eedd5a2c55ef) Plumb is_no_records_found() and into_soa() across all error types - [`a28dbac`](https://github.com/hickory-dns/hickory-dns/commit/a28dbac3ca3e9467fb105fb1dca2ff9833406291) Forward SOA records in NXDOMAIN ### 📊 Changes **5 files changed** (+155 additions, -20 deletions) <details> <summary>View changed files</summary> 📝 `crates/proto/src/error.rs` (+27 -0) 📝 `crates/recursor/src/error.rs` (+28 -0) 📝 `crates/resolver/src/error.rs` (+23 -0) 📝 `crates/server/src/authority/catalog.rs` (+46 -19) 📝 `crates/server/src/authority/error.rs` (+31 -1) </details> ### 📄 Description Currently, the forwarder handles both NXDOMAIN and SOA forwarding rather poorly. The is_nx_domain() check is incomplete & did not consider NXDOMAIN in `ResolveError`s and `RecursiveError`s. SOA records were outright ignored. This PR fixes those issues. Here's the result from `dig` when a nonexistent domain is queried: ``` ; <<>> DiG 9.20.1 <<>> @127.0.0.1 -p 8553 nothing.example.com ; (1 server found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 19646 ;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags: do; udp: 1232 ;; QUESTION SECTION: ;nothing.example.com. IN A ;; AUTHORITY SECTION: example.com. 1800 IN SOA ns.icann.org. noc.dns.icann.org. 2024081402 7200 3600 1209600 3600 ;; Query time: 203 msec ;; SERVER: 127.0.0.1#8553(127.0.0.1) (UDP) ;; WHEN: Fri Aug 23 21:53:56 +08 2024 ;; MSG SIZE rcvd: 115 ``` Compared to the result before: ``` ; <<>> DiG 9.20.1 <<>> @127.0.0.1 -p 8553 nothing.example.com ; (1 server found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 41628 ;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags: do; udp: 1232 ; OPT=5: 08 0d 0e 0f ("....") ; OPT=6: 08 0d 0e 0f ("....") ;; QUESTION SECTION: ;nothing.example.com. IN A ;; Query time: 420 msec ;; SERVER: 127.0.0.1#8553(127.0.0.1) (UDP) ;; WHEN: Fri Aug 23 22:08:33 +08 2024 ;; MSG SIZE rcvd: 64 ``` This closes #1891. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-16 11:19:35 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hickory-dns#2999
No description provided.