TechnitiumSoftware/DnsServer · error · ArgumentOutOfRangeException

Name server addresses cannot have more than 255 entries.

Error message

Name server addresses cannot have more than 255 entries.

What it means

Thrown by the NotifyNameServers setter when the supplied IPAddress collection has more than 255 entries. The notify name-server list is persisted with a single-byte count, so > 255 is rejected; null/empty clears it. Setting also resets the _notifyFailed tracking state.

Source

Thrown at DnsServerCore/Dns/Zones/ApexZone.cs:1388

            {
                _notify = value;

                lock (_notifyFailed)
                {
                    _notifyFailed.Clear();
                }
            }
        }

        public IReadOnlyCollection<IPAddress> NotifyNameServers
        {
            get { return _notifyNameServers; }
            set
            {
                if ((value is null) || (value.Count == 0))
                    _notifyNameServers = null;
                else if (value.Count > byte.MaxValue)
                    throw new ArgumentOutOfRangeException(nameof(NotifyNameServers), "Name server addresses cannot have more than 255 entries.");
                else
                    _notifyNameServers = value;

                lock (_notifyFailed)
                {
                    _notifyFailed.Clear();
                }
            }
        }

        public IReadOnlyCollection<IPAddress> NotifySecondaryCatalogNameServers
        {
            get { return _notifySecondaryCatalogNameServers; }
            set
            {
                if ((value is null) || (value.Count == 0))
                    _notifySecondaryCatalogNameServers = null;
                else if (value.Count > byte.MaxValue)

View on GitHub (pinned to d0484b6c1e)

Solutions

  1. Trim NotifyNameServers to <= 255 IP addresses.
  2. Route NOTIFY through a smaller set of forwarders/catalog secondaries rather than every leaf secondary.
  3. Deduplicate IPv4/IPv6 duplicates before assigning.

Example fix

// before
zone.NotifyNameServers = secondaries; // Count > 255 -> throws
// after
zone.NotifyNameServers = secondaries.Distinct().Take(255).ToList();
Defensive patterns

Strategy: validation

Validate before calling

if (servers != null && servers.Count > byte.MaxValue)
    throw new InvalidOperationException($"NotifyNameServers capped at 255 (got {servers.Count}).");
zone.NotifyNameServers = servers;

Type guard

static bool IsValidNotifyCount(IReadOnlyCollection<IPAddress> servers) => servers is null || servers.Count <= byte.MaxValue;

Try / catch

try { zone.NotifyNameServers = servers; }
catch (ArgumentOutOfRangeException ex) when (ex.ParamName == nameof(zone.NotifyNameServers))
{ zone.NotifyNameServers = servers.Distinct().Take(byte.MaxValue).ToList(); }

Prevention

When it happens

Trigger: Assigning > 255 NOTIFY target secondaries; importing a large secondary roster.

Common situations: Large multi-secondary deployments enumerating each IP; merging notify lists across zones.

Related errors


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