TechnitiumSoftware/DnsServer · error · DhcpServerException
Scope with name '{oldName}' does not exists.
Error message
Scope with name '{oldName}' does not exists. What it means
RenameScope could not find a scope under oldName in the scopes dictionary, so nothing to rename.
Source
Thrown at DnsServerCore/Dhcp/DhcpServer.cs:1446
{
await LoadScopeAsync(scope, false);
SaveScopeFile(scope);
}
public Scope GetScope(string name)
{
if (_scopes.TryGetValue(name, out Scope scope))
return scope;
return null;
}
public void RenameScope(string oldName, string newName)
{
Scope.ValidateScopeName(newName);
if (!_scopes.TryGetValue(oldName, out Scope scope))
throw new DhcpServerException("Scope with name '" + oldName + "' does not exists.");
if (!_scopes.TryAdd(newName, scope))
throw new DhcpServerException("Scope with name '" + newName + "' already exists.");
scope.Name = newName;
_scopes.TryRemove(oldName, out _);
SaveScopeFile(scope);
DeleteScopeFile(oldName);
}
public void DeleteScope(string name)
{
if (_scopes.TryGetValue(name, out Scope scope))
{
UnloadScope(scope, true);
DeleteScopeFile(scope.Name);
}View on GitHub (pinned to d0484b6c1e)
Solutions
- Verify the scope exists with GetScope(oldName) before renaming.
- Use the exact stored Name (mind casing).
- Refresh the scope list in the caller before issuing the rename.
Example fix
// before
_dhcpServer.RenameScope('Lan', 'lan2'); // stored name is 'lan'
// after
var s = _dhcpServer.GetScope('lan');
if (s != null) _dhcpServer.RenameScope(s.Name, 'lan2'); Defensive patterns
Strategy: validation
Validate before calling
if (_dhcpServer.GetScope(oldName) == null)
throw new InvalidOperationException($"Scope '{oldName}' not found"); Type guard
static bool ScopeExists(Func<string, Scope> getScope, string name) => getScope(name) != null;
Try / catch
try { _dhcpServer.RenameScope(oldName, newName); }
catch (DhcpServerException ex) when (ex.Message.Contains("does not exists"))
{ /* refresh scope list, use exact Name */ } Prevention
- Refresh the scope list before rename operations.
- Use the exact stored Name (mind casing).
- Guard with GetScope before RenameScope.
When it happens
Trigger: Calling RenameScope(oldName, newName) when `_scopes.TryGetValue(oldName, out _)` is false.
Common situations: Stale UI referencing a scope deleted meanwhile. Typo in oldName. Case-sensitivity mismatch (names are treated by dictionary key semantics).
Related errors
- Scope with overlapping range already exists: {existingScope.
- Scope with same name already exists.
- Scope with name '{newName}' already exists.
- The scope name contains an invalid character: {invalidChar}
- The address must be an IPv4 address: {startingAddress}
AI-assisted analysis of TechnitiumSoftware/DnsServer@d0484b6c1e (2026-08-13).
Data as JSON: /api/errors/619ae281e72e7dd0.
Report an issue: GitHub.