{"record":{"id":"9b7265bf216d608e","repo":"TechnitiumSoftware/DnsServer","slug":"exclusion-ending-address-must-be-in-scope-range","errorCode":null,"errorMessage":"Exclusion ending address must be in scope range.","messagePattern":"Exclusion ending address must be in scope range\\.","errorType":"validation","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Dhcp/Scope.cs","lineNumber":2144,"sourceCode":"\n        public IReadOnlyCollection<Exclusion> Exclusions\n        {\n            get { return _exclusions; }\n            set\n            {\n                if (value is null)\n                {\n                    _exclusions = null;\n                }\n                else\n                {\n                    foreach (Exclusion exclusion in value)\n                    {\n                        if (!IsAddressInRange(exclusion.StartingAddress))\n                            throw new ArgumentOutOfRangeException(nameof(Exclusions), \"Exclusion starting address must be in scope range.\");\n\n                        if (!IsAddressInRange(exclusion.EndingAddress))\n                            throw new ArgumentOutOfRangeException(nameof(Exclusions), \"Exclusion ending address must be in scope range.\");\n                    }\n\n                    _exclusions = value;\n                }\n            }\n        }\n\n        public IReadOnlyCollection<Lease> ReservedLeases\n        {\n            get\n            {\n                List<Lease> leases = new List<Lease>(_reservedLeases.Count);\n\n                foreach (KeyValuePair<ClientIdentifierOption, Lease> entry in _reservedLeases)\n                    leases.Add(entry.Value);\n\n                leases.Sort();\n                return leases;","sourceCodeStart":2126,"sourceCodeEnd":2162,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Dhcp/Scope.cs#L2126-L2162","documentation":"Thrown by the Exclusions setter when an exclusion's EndingAddress falls outside the scope's start..end range (IsAddressInRange returns false). Like the starting-address check, the exclusion end must be a real pool address.","triggerScenarios":"Setting scope.Exclusions = collection where any exclusion.EndingAddress is outside scope.StartingAddress..scope.EndingAddress. Common when an exclusion end equals the broadcast or a host beyond the pool.","commonSituations":"Exclusion end set to the broadcast address (which is outside the pool), stale exclusions after ChangeNetwork, or copy-paste from a larger scope.","solutions":["Filter exclusions so every EndingAddress lies within the scope range.","Avoid using the broadcast or network address as an exclusion bound.","Rebuild exclusions after ChangeNetwork.","Validate exclusion end bounds in config before assignment."],"exampleFix":"// before\nscope.Exclusions = rawExclusions;\n\n// after\nvar inRange = rawExclusions\n    .Where(e => IsInRange(e.StartingAddress, scope.StartingAddress, scope.EndingAddress)\n             && IsInRange(e.EndingAddress, scope.StartingAddress, scope.EndingAddress))\n    .ToList();\nscope.Exclusions = inRange;","handlingStrategy":"validation","validationCode":"static bool IsInRange(IPAddress a, IPAddress lo, IPAddress hi)\n    => Compare(a, lo) >= 0 && Compare(a, hi) <= 0;\n\nexclusions = exclusions\n    .Where(e => IsInRange(e.StartingAddress, scope.StartingAddress, scope.EndingAddress)\n             && IsInRange(e.EndingAddress, scope.StartingAddress, scope.EndingAddress))\n    .ToList();\nscope.Exclusions = exclusions;","typeGuard":"static bool ExclusionEndInRange(Exclusion e, IPAddress lo, IPAddress hi)\n    => IsInRange(e.EndingAddress, lo, hi);","tryCatchPattern":"try { scope.Exclusions = value; }\ncatch (ArgumentOutOfRangeException ex) when (ex.ParamName == \"Exclusions\" && ex.Message.Contains(\"ending address\"))\n{ /* filter exclusions and retry */ }","preventionTips":["Never use the broadcast address as an exclusion end (it is outside the pool).","Rebuild exclusions after ChangeNetwork.","Validate both bounds of each exclusion in config."],"tags":["dhcp","validation","scope","ipv4","exclusion","argument"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}