How to change the subnet mask of DHCP scope

19 June 2009

Changing the DHCP scope subnet mask

Change the subnet mask in existing DHCP scope

You can’t change the subnet mask of the DHCP scope directly without deleting the scope, need to delete the DHCP scope first then recreate the scope with new subnet, but this will lead to large amount of manual work

To avoid the manual work use the below netsh command to Change the subnet mask in existing DHCP scope with the simple steps

Use the below command to export the scope configuration

Syntex:

C:\>netsh dhcp server \\”Server name” scope “scope subnet” dump>c:\dhcp.txt

Example:

C:\>netsh dhcp server \\Test01 scope 192.168.1.0 dump>c:\dhcp.txt

To change the subnet mask of the scope

Open the dhcp.txt file and change the subnet mask, dhcp.txt file resemble the following


Changed the current scope context to 192.168.1.0 scope.

Dhcp Server 192.168.1.24 add scope 192.168.1.0 255.255.255.0 "Vlan-1" "Vlan-1"
Dhcp Server 192.168.1.24 Scope 192.168.1.0 set state 1


Edit the file and save

After this, delete the scope and run the below command to create the scope from the txt file

C:\>netsh exec c:\dhcp.txt

This will automatically create the DHCP scope with the new subnet mask

This way you can change other configuration details along with subnet mask change, like IP range and Excluderanges

Subscribe to Windowstricks by E-mail to get the free updates and free tools

Share this . . .

18 comments:

Diego,  11 May 2011 15:31  

Great post ! Worked for me on a 2008R2 machine saving the time of reconfiguring the whole DHCP Scope on 2 servers. Thank you!

Anonymous,  24 September 2011 08:11  

This is awesome.

Anonymous,  30 November 2011 14:30  

Thanks a lot!

It works, however, in addition to changing scope's mask in the dump-file, it is necessary to change its IP-address, too, to match its new mask. Otherwise the command:

C:\>netsh exec c:\alabala.txt

fails with appropriate error message.

Anonymous,  14 December 2011 06:26  

ive read this post and have one quick question i hope can be answered before i make the changes.
im just changing the subnet mask from 255.255.0.0 to 255.255.255.0.

When i delete the existing scope and quickly import the new one using this method.Will my clients automatically renew or does it need to be forced on the client..I dont want to make the change and have all the users calling as they have lost connectivity in a hospital enviroment.

Anonymous,  30 January 2012 09:44  

Worked great for me with one addition. My range was originally 10.144.67.0 with a subnet of 255.255.255.0. When i just changed the subnet to 255.255.252.0 the import woud fail with "bad parameter" I had to do a search and replace of the 10.144.67.0 with 10.144.64.0 and then it was able to import. Just found a simple subnet calculator online to tell me that a 252.0 subnet containing 67.0 had to start at 64.0.

Anonymous,  1 May 2012 23:14  

awesome .. double awesome .. just great .. thanks a bunch

Anonymous,  28 June 2012 16:52  

Thanks a lot!!!

Anonymous,  26 July 2012 20:29  

Thanks !!

Anonymous,  6 November 2012 02:43  

Thank you, from Italy!

Adam Kessler 22 November 2012 21:36  

There is a significant step left out in the process expressed above. One that can lead to significant frustrations and network down time.
The instructions to delete the scope after you have dumped the DHCP configuration is seriously incomplete. Before you can effective import a modified scope you must rename the dhcp.mdb and dhcp.pat files in the dhcp system folder. Without this step, the import process will always load the existing configuration and try to update it with the contents of the dump file. This will not work when attempting to change the network mask. The existing files must be renamed in order to create a new scope with the changed mask. I would highly suggest trying this on a non-production server first. I did so by first creating a new scope with the parameters I needed for the network definition. I did not define anything else. Once this was done, I dumped this to view the file for a scope as I needed it to be configured. I then copied out the parts reflecting the changes into the approriate areas of my production server's dump and then imported that into the test server and checked the DHCP gui for proper completion. Once I was sure this worked, I used this file to import the changes into my production server. In this case because of the need to change the network mask, I had to rename the ,mdb and .pat files on the production server to basically create the new scope.

Anonymous,  30 January 2013 00:13  

This worked on a 2008r2 server with multiple scopes, followed the process outlined to (almost) to the letter, I only needed to change one scope. Perhaps if you have only one scope you would need to delete your mdb files, it was not neccessary in my case. This saved me a lot of work, thank you!

Anonymous,  6 February 2013 14:30  

Notwork for windows2003 DHCP server...It is not changing the DHCP scope
subnet mask

Bayarbyamba Sambuu 12 March 2013 08:05  

Thank you very much! Works great! My scope IP and subnet was 172.22.100.0 255.255.255.0. I can change it 255.255.254.0.

Clay Tsuhako 27 August 2013 20:02  

This looks very good for what I would like to do (10.0.0.1-254/255.255.255.0 to 255.255.252.0). My question would be what would I have to do to the devices (servers, switches,etc.) that have static IPs and the old subnet mask of 255.255.255.0? Would I still have to manually change all their subnet masks to 255.255.252.0?

Anonymous,  9 January 2014 12:56  

Just did this and it works exactly as the instructions suggest. No need to rename dhcp mdb and pat files as another poster has suggested.

Thank You,  26 February 2014 09:32  

Awesome !!!!! worked like a charm. I had around 20 reservations in my scope and all got restored after changing Scope and mask both, in 10 seconds !!!!

Post a Comment

Followers

About Me

My Photo

I am Ganesh. Active Directory, Exchange, Windows Server and Migration Specialist, and author of www.windowstricks.in

Copyright   © 2014 - www.Windowstricks.in - all rights reserved | Powered by Blogger | Blogger template The Beach by Ourblogtemplates.com

Back to TOP