How to set DHCP scope lease time through netsh?

In this post, I am going to talk about how to set the lease time for a given scope in the DHCP server through netsh command-line. The command is a little unintuitive considering the fact that you won't be mentioning anything about lease time in the command itself. The fact that you are updating the lease time is specified through the option-id for the lease time option. Without delaying any longer, let me give the command:

netsh dhcp server scope set optionvalue 51 DWORD 3600

Let me explain this command: scope specifies that you are going to change the lease time of the scope whose id is 51 is the option-id for the option Lease time. This is an IETF assigned number: DWORD is the datatype of the lease-time option. And finally 3600 represents the option value in number of seconds.

Compare this to the way you edit the lease time in your snap-in. You right-click on the scope icon and click 'Properties' and change the lease time. That's it!! That's a lot simpler I must say....

Comments (6)
  1. Note that is not possible to set unlimites lease time by using set optionvalue 51 "-1". The command fails.

    What you do instead is uset set optionsvalue "4294967296", which works fine.

    (Yes, i had a little trouble on this)

  2. Question: I have a customer that has 5 DHCP servers that host many scopes. The customer wants to know…

  3. nice blog


  4. Shaan says:

    Just wondering, can we use a script along with netsh to rotate the IP of a computer from a range or increase it by one after xyz seconds ??

Comments are closed.

Skip to main content