TechnitiumSoftware/DnsServer · error · DhcpServerException

Scope with overlapping range already exists: {existingScope.

Error message

Scope with overlapping range already exists: {existingScope.StartingAddress}-{existingScope.EndingAddress}

What it means

LoadScopeAsync rejects a new scope because its range overlaps an existing one. Overlap is detected when the new scope's starting OR ending address falls inside an existing scope's range (IsAddressInRange). This prevents two DHCP scopes handing out the same addresses.

Source

Thrown at DnsServerCore/Dhcp/DhcpServer.cs:1231

            catch (Exception ex)
            {
                _log.Write(dhcpEP, "DHCP Server failed to deactivate scope: " + scope.Name, ex);

                if (throwException)
                    throw;
            }

            return false;
        }

        private async Task LoadScopeAsync(Scope scope, bool waitForInterface)
        {
            foreach (KeyValuePair<string, Scope> entry in _scopes)
            {
                Scope existingScope = entry.Value;

                if (existingScope.IsAddressInRange(scope.StartingAddress) || existingScope.IsAddressInRange(scope.EndingAddress))
                    throw new DhcpServerException("Scope with overlapping range already exists: " + existingScope.StartingAddress.ToString() + "-" + existingScope.EndingAddress.ToString());
            }

            if (!_scopes.TryAdd(scope.Name, scope))
                throw new DhcpServerException("Scope with same name already exists.");

            if (scope.Enabled)
            {
                if (!await ActivateScopeAsync(scope, waitForInterface))
                    scope.SetEnabled(false);
            }

            _log.Write("DHCP Server successfully loaded scope: " + scope.Name);
        }

        private void UnloadScope(Scope scope, bool removeDnsEntries)
        {
            if (scope.Enabled)
                DeactivateScope(scope, removeDnsEntries, false);

View on GitHub (pinned to d0484b6c1e)

Solutions

  1. Adjust the new scope's starting/ending addresses so they do not fall inside any existing scope range.
  2. Delete or shrink the conflicting existing scope first.
  3. Recheck the subnet math: ensure ranges are disjoint (end of A < start of B).

Example fix

// before
var scopeA = new Scope('A', Parse('192.168.1.100'), Parse('192.168.1.200'), Parse('255.255.255.0'), ...);
var scopeB = new Scope('B', Parse('192.168.1.150'), Parse('192.168.1.250'), ...); // overlaps A
// after: make ranges disjoint
var scopeB = new Scope('B', Parse('192.168.1.201'), Parse('192.168.1.250'), ...);
Defensive patterns

Strategy: validation

Validate before calling

foreach (var kv in _dhcpServer.GetScopes())
{
    if (kv.Value.IsAddressInRange(scope.StartingAddress) || kv.Value.IsAddressInRange(scope.EndingAddress))
        throw new InvalidOperationException($"Range overlaps scope '{kv.Key}'");
}

Type guard

static bool RangeIsDisjoint(Scope existing, IPAddress start, IPAddress end)
    => !existing.IsAddressInRange(start) && !existing.IsAddressInRange(end);

Try / catch

try { await _dhcpServer.LoadScopeAsync(scope, true); }
catch (DhcpServerException ex) when (ex.Message.Contains("overlapping range"))
{ /* read reported range from message, adjust new scope boundaries */ }

Prevention

When it happens

Trigger: Adding a scope where existingScope.IsAddressInRange(newScope.StartingAddress) || existingScope.IsAddressInRange(newScope.EndingAddress) is true for any already-loaded scope.

Common situations: Creating a second scope that extends or sits inside the first. Mistyped gateway/range. Splitting a /24 into two scopes with overlapping boundaries. Importing scopes from another server.

Related errors


AI-assisted analysis of TechnitiumSoftware/DnsServer@d0484b6c1e (2026-08-13). Data as JSON: /api/errors/3dbe1a976d98b082. Report an issue: GitHub.