Share via


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 10.0.0.0 set optionvalue 51 DWORD 3600

Let me explain this command: scope 10.0.0.0 specifies that you are going to change the lease time of the scope whose id is 10.0.0.0. 51 is the option-id for the option Lease time. This is an IETF assigned number: https://www.faqs.org/rfcs/rfc2132.html 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

  • Anonymous
    May 10, 2005
    The comment has been removed
  • Anonymous
    May 23, 2005
    RePost:
    http://www.yeyan.cn/Programming/DHCPNetsh.aspx
  • Anonymous
    July 10, 2006
    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)
  • Anonymous
    July 17, 2006
    Question: I have a customer that has 5 DHCP servers that host many scopes. The customer wants to know...
  • Anonymous
    June 09, 2010
    nice blogMeelissa_jackson
  • Anonymous
    September 09, 2011
    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 ??