TechnitiumSoftware/DnsServer · error · ArgumentOutOfRangeException
Exclusion starting address must be in scope range.
Error message
Exclusion starting address must be in scope range.
What it means
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.
Source
Thrown at DnsServerCore/Dhcp/Scope.cs:2141
get { return _genericOptions; }
set { _genericOptions = value; }
}
public IReadOnlyCollection<Exclusion> Exclusions
{
get { return _exclusions; }
set
{
if (value is null)
{
_exclusions = null;
}
else
{
foreach (Exclusion exclusion in value)
{
if (!IsAddressInRange(exclusion.StartingAddress))
throw new ArgumentOutOfRangeException(nameof(Exclusions), "Exclusion starting address must be in scope range.");
if (!IsAddressInRange(exclusion.EndingAddress))
throw new ArgumentOutOfRangeException(nameof(Exclusions), "Exclusion ending address must be in scope range.");
}
_exclusions = value;
}
}
}
public IReadOnlyCollection<Lease> ReservedLeases
{
get
{
List<Lease> leases = new List<Lease>(_reservedLeases.Count);
foreach (KeyValuePair<ClientIdentifierOption, Lease> entry in _reservedLeases)
leases.Add(entry.Value);View on GitHub (pinned to d0484b6c1e)
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.
Example fix
// before
scope.Exclusions = rawExclusions; // may contain out-of-range starts
// after
var inRange = rawExclusions
.Where(e => IsInRange(e.StartingAddress, scope.StartingAddress, scope.EndingAddress)
&& IsInRange(e.EndingAddress, scope.StartingAddress, scope.EndingAddress))
.ToList();
scope.Exclusions = inRange;
static bool IsInRange(IPAddress a, IPAddress lo, IPAddress hi) => Compare(a, lo) >= 0 && Compare(a, hi) <= 0; Defensive patterns
Strategy: validation
Validate before calling
static bool IsInRange(IPAddress a, IPAddress lo, IPAddress hi)
=> Compare(a, lo) >= 0 && Compare(a, hi) <= 0;
// strip exclusions whose start is out of range before assigning:
exclusions = exclusions
.Where(e => IsInRange(e.StartingAddress, scope.StartingAddress, scope.EndingAddress)
&& IsInRange(e.EndingAddress, scope.StartingAddress, scope.EndingAddress))
.ToList();
scope.Exclusions = exclusions; Type guard
static bool ExclusionStartInRange(Exclusion e, IPAddress lo, IPAddress hi)
=> IsInRange(e.StartingAddress, lo, hi); Try / catch
try { scope.Exclusions = value; }
catch (ArgumentOutOfRangeException ex) when (ex.ParamName == "Exclusions" && ex.Message.Contains("starting address"))
{ /* filter exclusions and retry */ } Prevention
- Rebuild exclusions whenever the scope range changes (ChangeNetwork).
- Do not reuse exclusion lists from a different scope.
- Validate exclusion bounds in config before assignment.
When it happens
Trigger: 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.
Common situations: Reusing exclusions from another scope, stale config after a ChangeNetwork call, or UI letting users enter addresses outside the pool.
Related errors
- Exclusion ending address must be in scope range.
- Ending address must be greater than starting address.
- Reserved address must be in scope range.
- Exclusion ending address must be greater than or equal to st
- The address must be an IPv4 address: {startingAddress}
AI-assisted analysis of TechnitiumSoftware/DnsServer@d0484b6c1e (2026-08-13).
Data as JSON: /api/errors/abe48569f1981032.
Report an issue: GitHub.