TechnitiumSoftware/DnsServer · error · ArgumentOutOfRangeException
Lease time in days must be between 0 to 999.
Error message
Lease time in days must be between 0 to 999.
What it means
Thrown by the LeaseTimeDays setter (ushort) when the value exceeds 999. The lease time is serialized/stored with a 3-digit cap, so values above 999 days are rejected as out of the supported range.
Source
Thrown at DnsServerCore/Dhcp/Scope.cs:1886
public bool Enabled
{ get { return _enabled; } }
public IPAddress StartingAddress
{ get { return _startingAddress; } }
public IPAddress EndingAddress
{ get { return _endingAddress; } }
public IPAddress SubnetMask
{ get { return _subnetMask; } }
public ushort LeaseTimeDays
{
get { return _leaseTimeDays; }
set
{
if (value > 999)
throw new ArgumentOutOfRangeException(nameof(LeaseTimeDays), "Lease time in days must be between 0 to 999.");
_leaseTimeDays = value;
}
}
public byte LeaseTimeHours
{
get { return _leaseTimeHours; }
set
{
if (value > 23)
throw new ArgumentOutOfRangeException(nameof(LeaseTimeHours), "Lease time in hours must be between 0 to 23.");
_leaseTimeHours = value;
}
}
public byte LeaseTimeMinutesView on GitHub (pinned to d0484b6c1e)
Solutions
- Clamp the input to the 0..999 range before assignment.
- Reject or warn on values above 999 in your config validation layer.
- If a longer lease is genuinely needed, note the library hard-caps at 999 days.
- Double-check units: the field is days, not seconds or hours.
Example fix
// before scope.LeaseTimeDays = (ushort)configDays; // throws if > 999 // after scope.LeaseTimeDays = (ushort)Math.Min(configDays, 999);
Defensive patterns
Strategy: validation
Validate before calling
if (days > 999) throw new ConfigurationException("LeaseTimeDays must be <= 999");
scope.LeaseTimeDays = (ushort)Math.Clamp(days, 0, 999); Type guard
static bool IsValidLeaseTimeDays(int days) => days >= 0 && days <= 999;
Try / catch
try { scope.LeaseTimeDays = value; }
catch (ArgumentOutOfRangeException ex) when (ex.ParamName == "LeaseTimeDays")
{ /* clamp and retry, or report to user */ } Prevention
- Bound the lease-time input in your UI/config schema to 0..999.
- Document that the field is in days, not seconds.
- Unit-test deserialization with extreme values.
When it happens
Trigger: Assigning scope.LeaseTimeDays = value where value > 999. Common with config deserialization feeding an unchecked integer, or a UI allowing thousands of days.
Common situations: Importing a config with a huge lease lifetime, unit confusion (passing seconds/days), or a slider without an upper bound.
Related errors
- Lease time in hours must be between 0 to 23.
- Lease time in minutes must be between 0 to 59.
- Ending address must be greater than starting address.
- Server host name cannot exceed 63 bytes.
- Boot file name cannot exceed 127 bytes.
AI-assisted analysis of TechnitiumSoftware/DnsServer@d0484b6c1e (2026-08-13).
Data as JSON: /api/errors/2a006f61d42215a2.
Report an issue: GitHub.