Modifying the Subnet Mask of a DHCP Scope on Windows Server

Date : March 20, 2023

Introduction

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.

Step 1: Export the existing DHCP scope

To export the scope configuration, use the netsh command:

netsh dhcp server \\HOSTNAME_OF_DHCP_SERVER scope 172.16.X.X dump > C:\dhcp.txt

or the PowerShell command:

Export-DhcpServer -ComputerName HOSTNAME_OF_DHCP_SERVER -Leases -File C:\dhcp.xml -Verbose -ScopeId 172.16.X.X

Step 2: Modify the DHCP config file

Once the configuration is exported, it can be modified with the new subnet mask. Open the exported file in notepad and amend the subnet mask as needed:

netsh method
PowerShell method

Step 3: delete the old DHCP scope

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.”

Deleting the DHCP scope

Step 4: import the new scope

To import the new scope configuration, use the netsh command:

netsh exec c:\dhcp.txt

or PowerShell command:

Import-DhcpServer -ComputerName HOSTNAME_OF_DHCP_SERVER -File C:\dhcp.xml -Verbose -ScopeId 172.16.X.X -Lease -BackupPatch C:\dhcp_backup

Validation

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.

Conclusion

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

@