KB ID 0001177
Problem
You have probably tried to do this and found he option ‘greyed out’ because in the DHCP management console you can’t change the subnet mask of a scope.
I needed to change a clients DHCP scope because I was changing their subnet from /24 to /16. I could have simply deleted and recreated the scope, but they has a lot of custom settings for their phone system, and hundreds of reservations (which I know is unusual).
Solution
I wrote an article a long time ago about migrating DHCP scopes, this process uses the same method to take a backup of the scope, then you can edit the subnet mask, and ‘re-import’ the scope again.
First take a backup of the scope, open an administrative command window, and run the following command;
netsh dhcp server \\”Server name” scope “scope subnet” dump>c\:dhcp.txt
i.e. netsh dhcp server \\Server-DC01 scope 10.0.0.0 dump >c:\temp\dhcp.txt
Then open the C:\dhcp.txt file, and locate the subnet mask;
Edit it accordingly, and save the changes.
You can now DELETE the live scope, then reimport the one you just edited with the following command;
netsh exec c:\temp\dhcp.txt
Note: As you can see even when is has successfully import dyou will still see a “The following command was not found d error“
On older, (pre Windows Server 2012 machines) use the following syntax instead;
netsh dhcp server import c:\temp\dhcp.txt all
Related Articles, References, Credits, or External Links
NA
31/05/2017
When I run the import command on 2012R2, I get the request is not supported.
31/05/2017
Is it from a 2003 DHCP Server? If so see http://support.microsoft.com/kb/962355
Pete
30/10/2017
I get the same thing as Miles when running the import on 2012 R2 servers. “The request is not supported.” The dump file is from the same sever. Just trying to edit subnet mask.
31/10/2017
There you go, updated for Server 2012 🙂
Pete
19/03/2018
My WDS server is on Windows Server 2016 and the second option worked for me
netsh exec C:\Temp\dhcp.txt
27/12/2019
Thanks a lot.
It worked for me at Windows Server 2016 at last.
18/08/2018
This is very helpful for me, Excellent……… 🙂
20/06/2019
When I run the import command on 2012R2 I get the request The following command was not found: .
{link}
25/06/2019
Hi Sorry it’s taken me a while to reply, I wanted to run up a 2012 server to make sure the post was still relevant, and the code was correct. The screenshots {above} are new ones I took today, so the procedure still works. Are you running the command window ‘as administrator’? See https://www.petenetlive.com/KB/Article/0000988 is UAC turned off, and can you try putting the export file in a sub folder i.e. so it’s NOT on the root of the C Drive.
Pete
24/12/2024
Hi PeteLong,
The server 2012r2 and after run cmd
“netsh dhcp server import c:\dhcp.text all “and return is (The request is not supported” or
“netsh exec c:\dhcp.txt” and return is (The following command was not found) or
“PS C:\Windows\system32> netsh dhcp server import c:\temp\dhcp.txt all
The request is not supported.
PS C:\Windows\system32> netsh exec c:\temp\dhcp.txt all
The syntax supplied for this command is not valid. Check help for the correct syntax.
Usage: exec
Remarks:
Loads the script file and runs it.
PS C:\Windows\system32>”
Any idea where I need to look at it . Thank you in advance and very much appreciate for your form.
02/01/2025
Have you tried the PowerShell commands?
16/08/2019
You should note that if you have issues importing it, make sure you go back into notepad, do a “save as” with Encoding: ANSI. that option is located in the drop down next to the “Save”.
23/09/2020
Thank you! Changing my text file as ANSI solved my import issues! I would not have thought of that! Great suggestion!
24/09/2021
Thanks man!! You save me!!
26/11/2019
Very useful. It worked for me from the first try. I did same few years ago, I remember, but then I used the old syntax (with import)
08/12/2019
This just saved me a bunch of time. Thanks for the great write up!
06/05/2020
No need to change the subnet mask on the router interface?
06/05/2020
Yes – and all other statically assigned IP addresses on the network, and possibly any dynamic routing, but the article is specific to DHCP scopes!
P
07/07/2020
Thank you So much, Excelling work, this really helped save bunch of time.
26/08/2020
Great job with the tutorial, thanks!
16/10/2020
I know this article is a few years old and am hoping you are still monitoring the comments… I was following your very clear guide, but during import of the txt file that contains the new mask, I receive an error: “The command needs a valid Scope IP Address”. I can re-import my old settings fine but the modification of the mask apparently isn’t enough. It seems I might need to yet modify the txt further but not sure what else I need to change. Any advice would be helpful. Thanks!
16/10/2020
Whats your source and destination Server OS, l’ll test it on the bench?
16/10/2020
Thanks for responding. I have an address pool starting 172.xxx.34.61. Current mask is 254.0. All IPs before .61 are static so none of those are picked up by DHCP. The DC is Server 2016 Standard. Aside from some member servers of 2012R2 all my relevant servers are 2016 Standard (DCs, VMs, Hosts). I am trying to simply change mask so I get 172.xxx.32.x thru 172.xxx.35.x (32-35). I am already operating 34-35. Do to IP crunch, I am attempting to expand IPs by changing mask. As mentioned, it seems I may need to modify the output dhcp.txt further–just don’t really know what. Thanks!
19/10/2020
OK well 172.xxx.34.61 with a 255.255.240.0 subnet is in the middle of 172.16.32.0 (usable 172.16.32.1 to 172.16.47.254) Those IPs you want are already in that range?
26/10/2020
Just wanted to let you know that I did finally resolve the import error. I changed all .34 entries in the export to .32, re-imported and it went well. I did have to Supernet in DHCP to get the additional IPs to become available. Thanks for your assistance.
04/02/2021
Hi Pete,
I am planning on changing my network from /22 to /20 in order to get a larger address pool as I am running out of available addresses.
Except for you command, what else would I need to do to my IP range in order to Include the extra odd 3000 addresses. Moving from 192.168.4.0 with a /22 to a /20.
05/02/2021
Other than the above change the subnet mask on your nodes that have static IP addresses.
09/08/2021
Hi, this looks great. I am getting ready to do this and it looks simple. I just wanted to confirm static assigned IPs. Do I need to go to each device that has a static IP and change the subnet mask? I am newer to this but with running out IPs this needs to get done.
For example we have IP phones that look like this:
IP 192.168.6.201
DNS 192.168.6.21
Gateway 192.168.6.1
Subnet Mask 255.255.255.0
After the subnet mask gets changed to 255.255.0.0 I realize I will need to change the address pool to include 192.168.7.254 or what ever third octet we go up to. But do I need to go to device then and change subnet mask or will it change since I edited the IP mask?
09/08/2021
Hi Ron,
To be honest yes – but things wont explode and stop working. Remember on a local subnet ARP will be resolving IP addresses to MAC addresses, If you have Cisco Switches they have PROXY ARP on anyway so you wont notice, but a phone on 192.168.6.201/24 will see any traffic that does not have a 6 as it’s third octet as needing to go the default gateway, if that gateway is a Cisco switch/router it will be fine, if it’s something less ‘enterpise’ then you could get a problem.
28/09/2021
When changing the subnet mask in a dhcp scope, do we not need to resubnet the rest of the network? routers, statically assigned addresses and such?
28/09/2021
Yes!
24/01/2022
Hi , I am receiving a error, the command needs a valid scope address after edit dhcp.txt file
I just change my subnet mask from 255.255.255.0 to 255.255.254.0
when i just exec the command by
netsh exec C:\dhcp.txt
receive the error, please help
26/02/2025
Not certain if anyone is still paying attention to this or not. I was trying to do this on my Windows 22 server and it gets mad at me when importing it, below is what it says. For context I’m changing one bit going from /24 to a /23 and I changed the range to end at 3.254, I’m starting at 2.0.
C:\Windows\system32>netsh exec c:\temp\dhcp.txt
The following command was not found: Changed the current scope context to 192.168.2.0 scope..
The scope parameters are incorrect. Either the scope already exists or its subnet address and mask is inconsistent with the subnet address and mask of an existing scope.
The command needs a valid Scope IP Address.
The command needs a valid Scope IP Address.
The command needs a valid Scope IP Address.