Private reverse lookups are answered locally, and single-label names are answered from an ordered chain of local sources instead of being sent to public upstreams, on by default #136

Open
opened 2026-10-31 12:42:13 -04:00 by claude · 0 comments
Owner
  • Draft: PQ-30
  • Priority: medium
  • Agent: coder
  • Depends on: #135
  • Decisions: Q-PQ-9, Q-PQ-11, R2-BARE

Why

See #134.

What changes

  • New options class DnsHygieneOptions, section DnsServer:Hygiene, in Ninlil.Dns.Server.Core/Hygiene/:
    • AnswerPrivateReverseLocally (default true)
    • KeepSingleLabelNamesLocal (default true)
    • #139 adds the rebind settings and #138 the local domain.
  • Registry entry, ENVIRONMENT.md rows and totals.
  • Shared LocalNetworkGuard in Ninlil.Dns.Server.Core/Hygiene/. Before going upstream:
    • A name inside a catalog reverse zone (LocallyServedZoneCatalog.CoversReverseZone) gets NXDOMAIN with an SOA, per RFC 6303 §3. The special-use names (home.arpa, internal, resolver.arpa, service.arpa) are never answered by this rule; resolver.arpa carries RFC 9462 discovery queries.
    • A single-label name is offered to every registered ILocalHostNameSource (new interface in the same folder), in ascending Order:
      • int Order { get; } and ValueTask<LocalHostNameAnswer> FindAsync(DnsName name, DnsResourceRecordTypeEnum type, IPAddress client, CancellationToken stoppingToken). LocalHostNameAnswer says whether the name exists and carries the records to answer with.
      • LocalHostNameSourceOrder (static class, same folder) holds the owner's order as constants: DhcpRegisteredNames = 100 (#137), HostsFiles = 200 (#175), LocalDomain = 300 (#138).
      • The first source that reports the name exists answers: NOERROR with its records, owned by the queried single-label name, AA clear; or NODATA when it has no record of the asked type.
      • No source finds it: with KeepSingleLabelNamesLocal on, NXDOMAIN with no SOA. Technical call: this server holds no zone for a bare name, so it has no SOA to give, and a host name that registers a minute later should not be hidden by a cached negative answer. With the option off, the query goes upstream as today.
      • Technical call: the sources are asked whatever KeepSingleLabelNamesLocal says. A name an operator registered by DHCP, listed in a hosts file or placed in the local-domain zone is meant to be answered; the option only decides whether an unknown bare name may leak upstream.
    • No source is registered by default; #137, #175 and #138 add theirs.
  • Called from ForwarderQueryResolver (global set only) and RecursiveQueryResolver.
  • The #101 outcome, when present, records AnswerSource = Server for the reverse and NXDOMAIN answers; a source sets its own (#137, #138).

Acceptance

  • Test fails first in src/dotnet/tests/Ninlil.Dns.Server.Forwarding.Tests: with default options, a PTR for 1.1.168.192.in-addr.arpa returns NXDOMAIN with an SOA and the fake upstream receives zero queries.
  • A forwarder zone 168.192.in-addr.arpa still forwards that PTR to its own upstream.
  • A query under resolver.arpa is not answered by the guard.
  • Same for src/dotnet/tests/Ninlil.Dns.Server.Recursive.Tests.
  • Single-label nas is never sent upstream; with a fake ILocalHostNameSource holding nas A 192.168.1.20, the reply is that record; without it, NXDOMAIN.
  • Two fake sources with orders 100 and 200 both holding nas with different addresses: the reply carries the order-100 address.
  • With KeepSingleLabelNamesLocal off, a fake source still answers nas, and an unknown foo goes upstream.
  • With both options false and no source, both queries go upstream as today.
  • Option change; README.

Source

  • RFC 6303 §3, §4; audit-feature-parity.md §2A #9.
  • Owner decision 2026-10-31 (Q-PQ-9): "reverse + single-label on, rebind off".
  • Owner decision 2026-10-31 (Q-PQ-11): "answer from DHCP-registered names first, then NXDOMAIN".
  • Owner decision 2026-10-31, round 2 (R2-BARE): DHCP names, then hosts files, then the local domain, then NXDOMAIN.
  • DEDUPE.md A2, A3.
- **Draft:** PQ-30 - **Priority:** medium - **Agent:** coder - **Depends on:** #135 - **Decisions:** Q-PQ-9, Q-PQ-11, R2-BARE ### Why See #134. ### What changes - New options class `DnsHygieneOptions`, section `DnsServer:Hygiene`, in `Ninlil.Dns.Server.Core/Hygiene/`: - `AnswerPrivateReverseLocally` (default true) - `KeepSingleLabelNamesLocal` (default true) - #139 adds the rebind settings and #138 the local domain. - Registry entry, ENVIRONMENT.md rows and totals. - Shared `LocalNetworkGuard` in `Ninlil.Dns.Server.Core/Hygiene/`. Before going upstream: - A name inside a catalog reverse zone (`LocallyServedZoneCatalog.CoversReverseZone`) gets NXDOMAIN with an SOA, per RFC 6303 §3. The special-use names (`home.arpa`, `internal`, `resolver.arpa`, `service.arpa`) are never answered by this rule; `resolver.arpa` carries RFC 9462 discovery queries. - A single-label name is offered to every registered `ILocalHostNameSource` (new interface in the same folder), in ascending `Order`: - `int Order { get; }` and `ValueTask<LocalHostNameAnswer> FindAsync(DnsName name, DnsResourceRecordTypeEnum type, IPAddress client, CancellationToken stoppingToken)`. `LocalHostNameAnswer` says whether the name exists and carries the records to answer with. - `LocalHostNameSourceOrder` (static class, same folder) holds the owner's order as constants: `DhcpRegisteredNames = 100` (#137), `HostsFiles = 200` (#175), `LocalDomain = 300` (#138). - The first source that reports the name exists answers: NOERROR with its records, owned by the queried single-label name, AA clear; or NODATA when it has no record of the asked type. - No source finds it: with `KeepSingleLabelNamesLocal` on, NXDOMAIN with no SOA. **Technical call:** this server holds no zone for a bare name, so it has no SOA to give, and a host name that registers a minute later should not be hidden by a cached negative answer. With the option off, the query goes upstream as today. - **Technical call:** the sources are asked whatever `KeepSingleLabelNamesLocal` says. A name an operator registered by DHCP, listed in a hosts file or placed in the local-domain zone is meant to be answered; the option only decides whether an unknown bare name may leak upstream. - No source is registered by default; #137, #175 and #138 add theirs. - Called from `ForwarderQueryResolver` (global set only) and `RecursiveQueryResolver`. - The #101 outcome, when present, records `AnswerSource = Server` for the reverse and NXDOMAIN answers; a source sets its own (#137, #138). ### Acceptance - [ ] Test fails first in `src/dotnet/tests/Ninlil.Dns.Server.Forwarding.Tests`: with default options, a PTR for `1.1.168.192.in-addr.arpa` returns NXDOMAIN with an SOA and the fake upstream receives zero queries. - [ ] A forwarder zone `168.192.in-addr.arpa` still forwards that PTR to its own upstream. - [ ] A query under `resolver.arpa` is not answered by the guard. - [ ] Same for `src/dotnet/tests/Ninlil.Dns.Server.Recursive.Tests`. - [ ] Single-label `nas` is never sent upstream; with a fake `ILocalHostNameSource` holding `nas A 192.168.1.20`, the reply is that record; without it, NXDOMAIN. - [ ] Two fake sources with orders 100 and 200 both holding `nas` with different addresses: the reply carries the order-100 address. - [ ] With `KeepSingleLabelNamesLocal` off, a fake source still answers `nas`, and an unknown `foo` goes upstream. - [ ] With both options false and no source, both queries go upstream as today. - [ ] Option change; README. ### Source - RFC 6303 §3, §4; `audit-feature-parity.md` §2A #9. - Owner decision 2026-10-31 (Q-PQ-9): "reverse + single-label on, rebind off". - Owner decision 2026-10-31 (Q-PQ-11): "answer from DHCP-registered names first, then NXDOMAIN". - Owner decision 2026-10-31, round 2 (R2-BARE): DHCP names, then hosts files, then the local domain, then NXDOMAIN. - DEDUPE.md A2, A3.
Sign in to join this conversation.
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.

Reference
lantea-one/ninlil#136
No description provided.