{"record":{"id":"83e293f5c430e960","repo":"TechnitiumSoftware/DnsServer","slug":"networks-cannot-have-more-than-255-entries","errorCode":null,"errorMessage":"Networks cannot have more than 255 entries.","messagePattern":"Networks cannot have more than 255 entries\\.","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Dns/DnsServer.cs","lineNumber":7206,"sourceCode":"\n        public DnsApplicationManager DnsApplicationManager\n        { get { return _dnsApplicationManager; } }\n\n        public IDnsCache DnsCache\n        { get { return _dnsCache; } }\n\n        public StatsManager StatsManager\n        { get { return _statsManager; } }\n\n        public IReadOnlyCollection<NetworkAddress> ZoneTransferAllowedNetworks\n        {\n            get { return _zoneTransferAllowedNetworks; }\n            set\n            {\n                if ((value is null) || (value.Count == 0))\n                    _zoneTransferAllowedNetworks = null;\n                else if (value.Count > byte.MaxValue)\n                    throw new ArgumentOutOfRangeException(nameof(ZoneTransferAllowedNetworks), \"Networks cannot have more than 255 entries.\");\n                else\n                    _zoneTransferAllowedNetworks = value;\n            }\n        }\n\n        public IReadOnlyCollection<NetworkAddress> NotifyAllowedNetworks\n        {\n            get { return _notifyAllowedNetworks; }\n            set\n            {\n                if ((value is null) || (value.Count == 0))\n                    _notifyAllowedNetworks = null;\n                else if (value.Count > byte.MaxValue)\n                    throw new ArgumentOutOfRangeException(nameof(NotifyAllowedNetworks), \"Networks cannot have more than 255 entries.\");\n                else\n                    _notifyAllowedNetworks = value;\n            }\n        }","sourceCodeStart":7188,"sourceCodeEnd":7224,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Dns/DnsServer.cs#L7188-L7224","documentation":"Thrown by the ZoneTransferAllowedNetworks property setter when the collection has more than 255 entries. The limit exists because zone-transfer ACLs are serialized into a single byte-counted structure (byte.MaxValue = 255). A null or empty collection is valid (clears the ACL to null).","triggerScenarios":"Assigning an IReadOnlyCollection<NetworkAddress> with Count > 255 to server.ZoneTransferAllowedNetworks.","commonSituations":"Loading a large allowlist from an external IP database; migrating from a system with unlimited ACL entries; dynamically generating the list from CIDR ranges without deduplication.","solutions":["Reduce the network list to 255 or fewer entries by aggregating smaller CIDRs into larger ranges.","Use a broader CIDR (e.g. /16) to cover many hosts with a single entry instead of listing individual /32s.","If the list comes from a file, trim or consolidate it before assignment."],"exampleFix":"// before\nvar nets = LoadLargeCidrList(); // 300 entries\nserver.ZoneTransferAllowedNetworks = nets; // throws\n\n// after\nvar consolidated = ConsolidateCidrs(nets); // merge into <255\nserver.ZoneTransferAllowedNetworks = consolidated;","handlingStrategy":"validation","validationCode":"if (networks != null && networks.Count > 255)\n    throw new InvalidOperationException(\"Consolidate CIDR list to <= 255 entries.\");\nserver.ZoneTransferAllowedNetworks = networks;","typeGuard":"static bool IsValidAclList(IReadOnlyCollection<NetworkAddress> nets) =>\n    nets is null || nets.Count <= 255;","tryCatchPattern":"try { server.ZoneTransferAllowedNetworks = networks; }\ncatch (ArgumentOutOfRangeException) { networks = ConsolidateCidrs(networks); server.ZoneTransferAllowedNetworks = networks; }","preventionTips":["Aggregate individual host entries into broader CIDRs before building the ACL.","Run an ACL-size check in config loading code before assigning."],"tags":["dns","zone-transfer","acl","configuration"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}