TechnitiumSoftware/DnsServer · error · DnsServerException
Zone cannot have sub domains.
Error message
Zone cannot have sub domains.
What it means
Thrown by GetOrAddSubDomainZone when the apex zone's concrete type does not match any of the supported sub-domain-capable classes. The if/else chain handles PrimaryZone, SecondaryCatalogZone, SecondaryZone, CatalogZone and ForwarderZone; every other ApexZone subtype falls through to this throw. In practice the only zone type that reaches here is StubZone, because stub zones only hold NS-delegation hints and cannot authoritatively serve child records.
Source
Thrown at DnsServerCore/Dns/ZoneManagers/AuthZoneManager.cs:766
internal AuthZone GetOrAddSubDomainZone(string zoneName, string domain)
{
return _root.GetOrAddSubDomainZone(zoneName, domain, delegate ()
{
if (!_root.TryGet(zoneName, out ApexZone apexZone))
throw new DnsServerException("Zone was not found for domain: " + domain);
if (apexZone is PrimaryZone primaryZone)
return new PrimarySubDomainZone(primaryZone, domain);
else if (apexZone is SecondaryCatalogZone secondaryCatalogZone)
return new SecondaryCatalogSubDomainZone(secondaryCatalogZone, domain);
else if (apexZone is SecondaryZone secondaryZone)
return new SecondarySubDomainZone(secondaryZone, domain);
else if (apexZone is CatalogZone catalogZone)
return new CatalogSubDomainZone(catalogZone, domain);
else if (apexZone is ForwarderZone forwarderZone)
return new ForwarderSubDomainZone(forwarderZone, domain);
throw new DnsServerException("Zone cannot have sub domains.");
});
}
internal IReadOnlyList<AuthZone> GetApexZoneWithSubDomainZones(string zoneName)
{
return _root.GetApexZoneWithSubDomainZones(zoneName);
}
public AuthZoneInfo GetAuthZoneInfo(string zoneName, bool loadHistory = false)
{
if (_root.TryGet(zoneName, out AuthZoneNode authZoneNode) && (authZoneNode.ApexZone is not null))
return new AuthZoneInfo(authZoneNode.ApexZone, loadHistory);
return null;
}
public AuthZoneInfo FindAuthZoneInfo(string domain, bool loadHistory = false)
{View on GitHub (pinned to d0484b6c1e)
Solutions
- Convert the Stub zone to a Primary, Secondary, Forwarder or Catalog zone so it can host sub-domains, using ConvertZoneTypeTo.
- Remove the child/delegation records under the Stub zone, or move them into an authoritative parent zone.
- Before calling APIs that resolve into sub-domains, check memberZoneInfo.Type/AuthZoneType and skip Stub zones.
- If you genuinely need delegation for the child, create a separate authoritative zone for the child name instead of relying on the Stub parent.
Example fix
// before: stub zone cannot host sub-domains
_root.GetOrAddSubDomainZone("example.com", "sub.example.com"); // throws for Stub
// after: ensure the apex is sub-domain-capable
if (apexZone is StubZone)
throw new InvalidOperationException($"Cannot create sub-domain under stub zone '{zoneName}'; convert to Primary/Secondary/Forwarder first.");
return _root.GetOrAddSubDomainZone(zoneName, domain); Defensive patterns
Strategy: type-guard
Validate before calling
// before GetOrAddSubDomainZone-equivalent logic, ensure the apex is sub-domain-capable
if (apexZone is StubZone)
throw new InvalidOperationException($"Stub zone '{zoneName}' cannot host sub-domains."); Type guard
static bool CanHaveSubDomains(ApexZone z) => z is PrimaryZone or SecondaryZone or SecondaryForwarderZone or SecondaryCatalogZone or CatalogZone or ForwarderZone;
Prevention
- Never rely on a Stub zone to serve child records; keep child delegations in an authoritative parent.
- Filter Stub zones out of any workflow that auto-creates sub-domain zones.
- Convert Stub zones to Primary/Secondary/Forwarder before delegating children.
When it happens
Trigger: The resolver requests a name that is a child/sub-domain of an existing Stub zone and the manager attempts GetOrAddSubDomainZone(zoneName, domain) for that zone. A Stub apex zone is found by _root.TryGet, none of the 'is PrimaryZone/Secondary*/CatalogZone/ForwarderZone' branches match, and execution reaches line 766.
Common situations: Configuring a Stub zone (AuthZoneType.Stub) for a domain like 'example.com' and then querying or adding records under a delegated child such as 'sub.example.com'. Migrating from a Primary/Secondary zone to a Stub while child delegations still exist. Tooling that auto-creates sub-domain zones from a zone list without filtering Stub zones.
Related errors
- Zone was not found for domain: {key}
- Zone was not found: {zoneName}
- The domain name '<domain>' does not belong to the zone: <zon
- DNS zone type not supported.
- Zone already exists: <zoneInfo.DisplayName>
AI-assisted analysis of TechnitiumSoftware/DnsServer@d0484b6c1e (2026-08-13).
Data as JSON: /api/errors/f7ecc5cfeb6b1d09.
Report an issue: GitHub.