TechnitiumSoftware/DnsServer · error · DnsServerException

The record type is not supported by primary zones.

Error message

The record type is not supported by primary zones.

What it means

Thrown by PrimaryZone.SetRecords() when the requested type is FWD. Forward records are a feature of forwarder/stub zones, not primary zones; a primary zone is authoritative and cannot contain forwarding directives, so the type is rejected.

Source

Thrown at DnsServerCore/Dns/Zones/PrimaryZone.cs:2601

                            case AuthZoneDnssecStatus.SignedWithNSEC3:
                                RefreshNSec3();
                                break;
                        }
                    }

                    TriggerNotify();
                    break;

                case DnsResourceRecordType.DNSKEY:
                case DnsResourceRecordType.RRSIG:
                case DnsResourceRecordType.NSEC:
                case DnsResourceRecordType.NSEC3PARAM:
                case DnsResourceRecordType.NSEC3:
                    throw new InvalidOperationException("Cannot set DNSSEC records.");

                case DnsResourceRecordType.FWD:
                    throw new DnsServerException("The record type is not supported by primary zones.");

                default:
                    if (records[0].OriginalTtlValue > GetZoneSoaExpire())
                        throw new DnsServerException("Cannot set records: TTL cannot be greater than SOA EXPIRE.");

                    if (!TrySetRecords(type, records, out IReadOnlyList<DnsResourceRecord> deletedRecords))
                        throw new DnsServerException("Cannot set records. Please try again.");

                    CommitAndIncrementSerial(deletedRecords, records);

                    if (_dnssecStatus != AuthZoneDnssecStatus.Unsigned)
                        UpdateDnssecRecordsFor(this, type);

                    TriggerNotify();
                    break;
            }
        }

View on GitHub (pinned to d0484b6c1e)

Solutions

  1. Do not set FWD records on a primary zone; FWD belongs only to forwarder zones.
  2. Route FWD record management to the correct zone type (forwarder/stub zone).
  3. Guard the call with a zone-type check or filter FWD from the input.

Example fix

// before
zone.SetRecords(DnsResourceRecordType.FWD, fwdRecords); // throws on primary zone

// after
if (zone.GetZoneTypeName() == "Forwarder")
    zone.SetRecords(DnsResourceRecordType.FWD, fwdRecords);
Defensive patterns

Strategy: type-guard

Validate before calling

if (type == DnsResourceRecordType.FWD && zone.GetZoneTypeName() == "Primary")
    throw new ArgumentException("FWD records belong to forwarder zones, not primary zones.");

zone.SetRecords(type, records);

Type guard

static bool IsTypeSupportedByZone(DnsResourceRecordType t, Zone z) =>
    !(t == DnsResourceRecordType.FWD && z.GetZoneTypeName() == "Primary");

Try / catch

try { zone.SetRecords(type, records); }
catch (DnsServerException ex) when (ex.Message == "The record type is not supported by primary zones.")
{ Log.Error($"{type} not supported on zone type '{zone.GetZoneTypeName()}'."); }

Prevention

When it happens

Trigger: Calling SetRecords(DnsResourceRecordType.FWD, ...) on a primary zone.

Common situations: Generic zone-editing code that applies the same record set across zone types; importing a forwarder zone's FWD records into a primary zone; misidentifying a zone's type before editing.

Related errors


AI-assisted analysis of TechnitiumSoftware/DnsServer@d0484b6c1e (2026-08-13). Data as JSON: /api/errors/9d37b50be7dd0c1e. Report an issue: GitHub.