{"record":{"id":"9e55a0e67662a35d","repo":"TechnitiumSoftware/DnsServer","slug":"exclusion-ending-address-must-be-greater-than-or-e","errorCode":null,"errorMessage":"Exclusion ending address must be greater than or equal to starting address.","messagePattern":"Exclusion ending address must be greater than or equal to starting address\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Dhcp/Exclusion.cs","lineNumber":40,"sourceCode":"using TechnitiumLibrary.Net;\n\nnamespace DnsServerCore.Dhcp\n{\n    public class Exclusion\n    {\n        #region variables\n\n        readonly IPAddress _startingAddress;\n        readonly IPAddress _endingAddress;\n\n        #endregion\n\n        #region constructor\n\n        public Exclusion(IPAddress startingAddress, IPAddress endingAddress)\n        {\n            if (startingAddress.ConvertIpToNumber() > endingAddress.ConvertIpToNumber())\n                throw new ArgumentException(\"Exclusion ending address must be greater than or equal to starting address.\");\n\n            _startingAddress = startingAddress;\n            _endingAddress = endingAddress;\n        }\n\n        #endregion\n\n        #region properties\n\n        public IPAddress StartingAddress\n        { get { return _startingAddress; } }\n\n        public IPAddress EndingAddress\n        { get { return _endingAddress; } }\n\n        #endregion\n    }\n}","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Dhcp/Exclusion.cs#L22-L58","documentation":"Exclusion constructor validates that the ending address is not numerically before the starting address (using ConvertIpToNumber). An exclusion is an address range removed from a DHCP scope, so it must be a valid ordered range.","triggerScenarios":"new Exclusion(startingAddress, endingAddress) with startingAddress.ConvertIpToNumber() > endingAddress.ConvertIpToNumber().","commonSituations":"UI form fields entered in the wrong order. Copy-paste of gateway/high-address into the 'from' field. IPv4 ordering assumption error.","solutions":["Swap the two addresses so starting <= ending (numerically).","Validate/sort the pair before constructing: pass (min, max)."],"exampleFix":"// before\nvar ex = new Exclusion(Parse('192.168.1.200'), Parse('192.168.1.100'));\n// after\nvar (lo, hi) = (Parse('192.168.1.100'), Parse('192.168.1.200'));\nvar ex = new Exclusion(lo, hi);","handlingStrategy":"validation","validationCode":"if (startingAddress.ConvertIpToNumber() > endingAddress.ConvertIpToNumber())\n    (startingAddress, endingAddress) = (endingAddress, startingAddress);","typeGuard":"static bool ExclusionOrdered(IPAddress start, IPAddress end) => start.ConvertIpToNumber() <= end.ConvertIpToNumber();","tryCatchPattern":"try { new Exclusion(start, end); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"greater than or equal to starting\"))\n{ /* swap start/end, retry */ }","preventionTips":["Normalize (min, max) before constructing an Exclusion.","Sort range endpoints at the UI/config boundary.","Unit-test exclusion parsing with reversed inputs."],"tags":["dhcp","exclusion","ipv4","validation"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}