A single-label query is answered from the host names DHCP registered in DNS #137

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

Why

The owner chose to answer bare names from DHCP-registered names first. The data exists: for an active lease with a usable host name, DhcpDnsRegistrationService writes an A (or AAAA) record named <label>.<zone> in the zone of the scope's DnsZoneId, marked ManagedByFeature = Dhcp (src/dotnet/src/Ninlil.Dhcp.Server.DnsIntegration/DhcpDnsRegistrationService.cs:154-161, :403-429). It removes the record when the lease ends (:142-151) and refuses names that clash with static records or a live client (:164-217). Those records are in memory in AuthoritativeZoneCache, and CachedZone.GetRecords returns RecordEntity rows with ManagedByFeature (src/dotnet/src/Ninlil.Dns.Server.Authoritative/Cache/CachedZone.cs:165-178).

Technical call: answer from these registered records, not from lease host names. They already apply the conflict rules (static wins, a live client keeps its name, and the per-scope host-name policy of #186), they expire with the lease, and they cost no database read per query. A scope without a DnsZoneId registers nothing, so its clients are not answered by this source; README says so.

What changes

  • src/dotnet/src/Ninlil.Dhcp.Server.DnsIntegration/DhcpRegisteredHostNameSource.cs (new), implementing ILocalHostNameSource (#136) with Order = LocalHostNameSourceOrder.DhcpRegisteredNames (first):
    • A RefreshingSnapshot of the DHCP scopes that have a DnsZoneId of an eligible type (DhcpDnsRegistrationService.IsEligibleZoneType, :351): zone name, protocol and address range. It expires on IEntityChangeNotifier for DhcpScopeEntity and ZoneEntity, with a 60 s time-to-live like the other snapshots.
    • Lookup for nas: zones in order, the zone of a scope whose range holds the client's address first, then the rest by zone name. For each, AuthoritativeZoneCache.FindZone("nas.<zone>") then GetRecords("nas.<zone>"), keeping only records with ManagedByFeature == Dhcp of type A or AAAA. The first zone with any such record wins.
    • The returned records are copies owned by the bare name, with the stored TTL (300 s).
    • Static records an operator added at nas.<zone> are not used by this source; the local domain (#138) answers them, after the hosts files.
  • ServiceCollectionDhcpDnsIntegrationExtension: register it as an ILocalHostNameSource. The integration is registered in every configuration (src/dotnet/src/Ninlil.Web/Startup/DhcpServiceRegistration.cs:78-85), so the source is always present and simply finds nothing without DHCP zones.
  • #101 outcome, when present: AnswerSource = Authoritative, Upstream = null.
  • README "Home network defaults": bare names resolve for DHCP clients whose scope has a DNS zone, before hosts files and the local domain.

Acceptance

  • Test fails first in src/dotnet/tests/Ninlil.Dhcp.Server.DnsIntegration.Tests: zone lan holds DHCP-managed nas.lan A 192.168.1.20; FindAsync("nas", A, client) returns one A record nas 300 A 192.168.1.20.
  • Test: an AAAA query for nas with only an A record gives "exists, no records" (NODATA).
  • Test: a static (not DHCP-managed) printer.lan gives not found from this source.
  • Test: with nas registered in zones a.lan and b.lan, a client inside the scope of b.lan gets the b.lan address.
  • Test: after the lease's record is removed and the zone reloads, nas is not found.
  • Test: Order equals LocalHostNameSourceOrder.DhcpRegisteredNames.
  • src/dotnet/tests/Ninlil.Web.Tests passes (DI wiring). No schema, API or option change.

Source

  • Owner decision 2026-10-31 (Q-PQ-11): "answer from DHCP-registered names first, then NXDOMAIN (needs DDNS integration; larger)".
  • Owner decision 2026-10-31, round 2 (R2-BARE): DHCP names come first in the bare-name order.
- **Draft:** PQ-35 - **Priority:** medium - **Agent:** coder - **Depends on:** #136 - **Decisions:** Q-PQ-11, R2-BARE ### Why The owner chose to answer bare names from DHCP-registered names first. The data exists: for an active lease with a usable host name, `DhcpDnsRegistrationService` writes an A (or AAAA) record named `<label>.<zone>` in the zone of the scope's `DnsZoneId`, marked `ManagedByFeature = Dhcp` (`src/dotnet/src/Ninlil.Dhcp.Server.DnsIntegration/DhcpDnsRegistrationService.cs:154-161`, `:403-429`). It removes the record when the lease ends (`:142-151`) and refuses names that clash with static records or a live client (`:164-217`). Those records are in memory in `AuthoritativeZoneCache`, and `CachedZone.GetRecords` returns `RecordEntity` rows with `ManagedByFeature` (`src/dotnet/src/Ninlil.Dns.Server.Authoritative/Cache/CachedZone.cs:165-178`). **Technical call:** answer from these registered records, not from lease host names. They already apply the conflict rules (static wins, a live client keeps its name, and the per-scope host-name policy of #186), they expire with the lease, and they cost no database read per query. A scope without a `DnsZoneId` registers nothing, so its clients are not answered by this source; README says so. ### What changes - `src/dotnet/src/Ninlil.Dhcp.Server.DnsIntegration/DhcpRegisteredHostNameSource.cs` (new), implementing `ILocalHostNameSource` (#136) with `Order = LocalHostNameSourceOrder.DhcpRegisteredNames` (first): - A `RefreshingSnapshot` of the DHCP scopes that have a `DnsZoneId` of an eligible type (`DhcpDnsRegistrationService.IsEligibleZoneType`, `:351`): zone name, protocol and address range. It expires on `IEntityChangeNotifier` for `DhcpScopeEntity` and `ZoneEntity`, with a 60 s time-to-live like the other snapshots. - Lookup for `nas`: zones in order, the zone of a scope whose range holds the client's address first, then the rest by zone name. For each, `AuthoritativeZoneCache.FindZone("nas.<zone>")` then `GetRecords("nas.<zone>")`, keeping only records with `ManagedByFeature == Dhcp` of type A or AAAA. The first zone with any such record wins. - The returned records are copies owned by the bare name, with the stored TTL (300 s). - Static records an operator added at `nas.<zone>` are not used by this source; the local domain (#138) answers them, after the hosts files. - `ServiceCollectionDhcpDnsIntegrationExtension`: register it as an `ILocalHostNameSource`. The integration is registered in every configuration (`src/dotnet/src/Ninlil.Web/Startup/DhcpServiceRegistration.cs:78-85`), so the source is always present and simply finds nothing without DHCP zones. - #101 outcome, when present: `AnswerSource = Authoritative`, `Upstream = null`. - README "Home network defaults": bare names resolve for DHCP clients whose scope has a DNS zone, before hosts files and the local domain. ### Acceptance - [ ] Test fails first in `src/dotnet/tests/Ninlil.Dhcp.Server.DnsIntegration.Tests`: zone `lan` holds DHCP-managed `nas.lan A 192.168.1.20`; `FindAsync("nas", A, client)` returns one A record `nas 300 A 192.168.1.20`. - [ ] Test: an AAAA query for `nas` with only an A record gives "exists, no records" (NODATA). - [ ] Test: a static (not DHCP-managed) `printer.lan` gives not found from this source. - [ ] Test: with `nas` registered in zones `a.lan` and `b.lan`, a client inside the scope of `b.lan` gets the `b.lan` address. - [ ] Test: after the lease's record is removed and the zone reloads, `nas` is not found. - [ ] Test: `Order` equals `LocalHostNameSourceOrder.DhcpRegisteredNames`. - [ ] `src/dotnet/tests/Ninlil.Web.Tests` passes (DI wiring). No schema, API or option change. ### Source - Owner decision 2026-10-31 (Q-PQ-11): "answer from DHCP-registered names first, then NXDOMAIN (needs DDNS integration; larger)". - Owner decision 2026-10-31, round 2 (R2-BARE): DHCP names come first in the bare-name order.
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#137
No description provided.