TechnitiumSoftware/DnsServer · error · ArgumentOutOfRangeException
Reserved address must be in scope range.
Error message
Reserved address must be in scope range.
What it means
Thrown by the ReservedLeases setter when a reserved lease's Address lies outside the scope's start..end range (IsAddressInRange returns false). Reservations must pin an address that belongs to the pool, so an out-of-range reservation is rejected.
Source
Thrown at DnsServerCore/Dhcp/Scope.cs:2179
leases.Sort();
return leases;
}
set
{
if ((value is null) || (value.Count == 0))
{
//remove all DNS entries
foreach (KeyValuePair<ClientIdentifierOption, Lease> entry in _reservedLeases)
_dhcpServer.RemoveDnsEntries(this, entry.Value, true);
_reservedLeases.Clear();
}
else
{
foreach (Lease reservedLease in value)
{
if (!IsAddressInRange(reservedLease.Address))
throw new ArgumentOutOfRangeException(nameof(ReservedLeases), "Reserved address must be in scope range.");
}
//remove DNS entries for reserved leases being removed or has updated domain name
foreach (KeyValuePair<ClientIdentifierOption, Lease> entry in _reservedLeases)
{
Lease existingReservedLease = entry.Value;
bool domainNameMatches = false;
foreach (Lease reservedLease in value)
{
if (existingReservedLease.ClientIdentifier.Equals(reservedLease.ClientIdentifier))
{
domainNameMatches = (existingReservedLease.HostName is null) || existingReservedLease.HostName.Equals(reservedLease.HostName, StringComparison.Ordinal);
break;
}
}
if (!domainNameMatches)View on GitHub (pinned to d0484b6c1e)
Solutions
- Filter reservations so every Address lies within scope.StartingAddress..scope.EndingAddress.
- After ChangeNetwork, migrate or drop reservations that fall outside the new range.
- Validate reservation addresses in your config layer.
- Do not reserve the network or broadcast address.
Example fix
// before
scope.ReservedLeases = reservations; // may contain out-of-range addresses
// after
var inRange = reservations
.Where(r => IsInRange(r.Address, scope.StartingAddress, scope.EndingAddress))
.ToList();
scope.ReservedLeases = inRange; Defensive patterns
Strategy: validation
Validate before calling
static bool IsInRange(IPAddress a, IPAddress lo, IPAddress hi)
=> Compare(a, lo) >= 0 && Compare(a, hi) <= 0;
reservations = reservations
.Where(r => IsInRange(r.Address, scope.StartingAddress, scope.EndingAddress))
.ToList();
scope.ReservedLeases = reservations; Type guard
static bool ReservationInRange(Lease r, IPAddress lo, IPAddress hi)
=> IsInRange(r.Address, lo, hi); Try / catch
try { scope.ReservedLeases = value; }
catch (ArgumentOutOfRangeException ex) when (ex.ParamName == "ReservedLeases")
{ /* drop out-of-range reservations and retry */ } Prevention
- Migrate or drop reservations after ChangeNetwork.
- Never reserve the network or broadcast address.
- Validate reservation addresses in config before assignment.
When it happens
Trigger: Setting scope.ReservedLeases = collection where any reservedLease.Address is below the scope start or above the scope end. Common after ChangeNetwork moves the range without updating reservations.
Common situations: Migrating reservations between scopes, stale config after a network change, or reserving the broadcast/network address.
Related errors
- Ending address must be greater than starting address.
- Exclusion starting address must be in scope range.
- Exclusion ending address must be in scope range.
- The address must be an IPv4 address: {startingAddress}
- The address must be an IPv4 address: {endingAddress}
AI-assisted analysis of TechnitiumSoftware/DnsServer@d0484b6c1e (2026-08-13).
Data as JSON: /api/errors/ccc0eca2d8dd3544.
Report an issue: GitHub.