{"record":{"id":"abe48569f1981032","repo":"TechnitiumSoftware/DnsServer","slug":"exclusion-starting-address-must-be-in-scope-range","errorCode":null,"errorMessage":"Exclusion starting address must be in scope range.","messagePattern":"Exclusion starting address must be in scope range\\.","errorType":"validation","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Dhcp/Scope.cs","lineNumber":2141,"sourceCode":"            get { return _genericOptions; }\n            set { _genericOptions = value; }\n        }\n\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);","sourceCodeStart":2123,"sourceCodeEnd":2159,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Dhcp/Scope.cs#L2123-L2159","documentation":"Thrown by the Exclusions setter when an exclusion's StartingAddress falls outside the scope's start..end range (IsAddressInRange returns false). Exclusions must carve out addresses already inside the pool, so an out-of-range start is invalid.","triggerScenarios":"Setting scope.Exclusions = collection where any exclusion.StartingAddress is below the scope starting address or above the scope ending address. Also when the scope range changed but exclusions were not recomputed.","commonSituations":"Reusing exclusions from another scope, stale config after a ChangeNetwork call, or UI letting users enter addresses outside the pool.","solutions":["Filter exclusions so every StartingAddress lies within scope.StartingAddress..scope.EndingAddress.","After ChangeNetwork, rebuild the exclusions list against the new range.","Validate exclusion bounds in your config layer before assignment.","Drop exclusions that no longer apply rather than passing them through."],"exampleFix":"// before\nscope.Exclusions = rawExclusions; // may contain out-of-range starts\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;\n\nstatic bool IsInRange(IPAddress a, IPAddress lo, IPAddress hi) => Compare(a, lo) >= 0 && Compare(a, hi) <= 0;","handlingStrategy":"validation","validationCode":"static bool IsInRange(IPAddress a, IPAddress lo, IPAddress hi)\n    => Compare(a, lo) >= 0 && Compare(a, hi) <= 0;\n\n// strip exclusions whose start is out of range before assigning:\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 ExclusionStartInRange(Exclusion e, IPAddress lo, IPAddress hi)\n    => IsInRange(e.StartingAddress, lo, hi);","tryCatchPattern":"try { scope.Exclusions = value; }\ncatch (ArgumentOutOfRangeException ex) when (ex.ParamName == \"Exclusions\" && ex.Message.Contains(\"starting address\"))\n{ /* filter exclusions and retry */ }","preventionTips":["Rebuild exclusions whenever the scope range changes (ChangeNetwork).","Do not reuse exclusion lists from a different scope.","Validate exclusion bounds in config before assignment."],"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"}