Modifying the Subnet Mask of a DHCP Scope on Windows Server
In certain situations, it may be necessary to change the subnet mask of a DHCP scope on a Windows Server. This can be done through a series of steps, including: exporting the DHCP scope configuration, modifying the configuration with the new subnet mask, deleting the DHCP scope, and importing the new configuration.
Modifying the Subnet Mask
The modifications can be made using either PowerShell cmdlets or the netsh utility from a command prompt in administrator mode.
To export the scope configuration, use the command:
netsh dhcp server \\HOSTNAME_OF_DHCP_SERVER scope 172.16.X.X dump > C:\dhcp.txt
Export-DhcpServer -ComputerName HOSTNAME_OF_DHCP_SERVER -Leases -File C:\dhcp.xml -Verbose -ScopeId 172.16.X.X
Once the configuration is exported, it can be modified with the new subnet mask. Open the exported file in notepad.
After the modifications are made, the DHCP scope must be deleted before importing the new configuration file. To delete the scope, right-click on the range and select “Delete.”
To import the new scope configuration, use the command:
netsh exec c:\dhcp.txt
Import-DhcpServer -ComputerName HOSTNAME_OF_DHCP_SERVER -File C:\dhcp.xml -Verbose -ScopeId 172.16.X.X -Lease -BackupPatch C:\dhcp_backup
To ensure that the scope has been properly imported and the new mask is applied, check in the DHCP console that the scope has been imported and check the properties to verify that the new mask is properly applied.
If you are using a DHCP failover configuration, you must reconfigure the scope failover and update any equipment with a fixed IP configuration.
Modifying the subnet mask of a DHCP scope on a Windows Server can be a complex process, but by following the steps outlined in this article and preparing for the change in advance, the process can be successfully completed. Always be sure to validate and ensure the new scope will not clash with an existing one, and schedule the change at a time when the load on the network is light. Make sure to also reconfigure the DHCP failover if you are using it.