none
Delete DHCP leases in batch?

    Question

  • Hi,

    I want to be able to schedule regular deletion of all leases in a scope  To that end, I've been looking for a command line way to delete leases.  So far, no luck.

    I was hopeful when I came across netsh, but eventually I came to believe that the only deletion available in netsh is deleting addresses from a scope, and that's not what I'm looking for.

    Anyone know what could be used to schedule deleting leases?

    (BTW - Cleanup doesn't seem to do what's needed.  What's happening is people can't get leases, even though dhcp management says the scope is not 100% used (sometimes well below 100%).  If I manually delete all the leases, by selecting them all in dhcp management and deleting, everything is OK again, even though scope utilization climbs fairly quickly back to the same percentage it was at before deleting...)

    TIA...

    Monday, December 13, 2010 9:52 PM

All replies

  • for that reason you can set a lease time in your DHCP config.

    Manually rebuilding this process would mean you have to:

     - get all leases

     - filter these leases to find the ones older than <your lease time>

     - delete the filtered leases.

    double check your DHCP config, it works as it supposed to do.

    for your reference: NETSH dhcp commands:

    http://technet.microsoft.com/en-us/library/cc787375(WS.10).aspx

    hth

    Gregor Stefka

    • Proposed as answer by Tiger Li Tuesday, December 14, 2010 8:02 AM
    Monday, December 13, 2010 10:12 PM
  • Hi,

     

    Thanks for posting here.

     

    You may try periodically perform “ipconfig /release” on client side by defining schedule task or reduce lease time on server.

    Some suggestions could be found in the link below:

     

    http://blogs.technet.com/b/teamdhcp/archive/2007/02/07/configuring-lease-time.aspx

     

    Thanks.

     

    Tiger Li


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    Tuesday, December 14, 2010 8:16 AM
  • Hi Gregor, Tiger,

    Thanks for your responses, but a couple of issues:

    Gregor - I've tried variations on the lease time (as short as 15 minutes), and it doesn't solve the problem described above.  Also, when I use the DHCP Management to deleted the leases, I don't pay any attention the time of the lease, I just delete them all.  This doesn't cause problems - as defined by the DHCP RFC, clients simply renew.  It's completely transparent to the user that the lease was deleted and renewed.

    Tiger - This is for our wireless vlan - I don't have access to the clients to set them up for schedule release/renew.

    Tuesday, December 14, 2010 6:53 PM
  • Hi,

     

    Thanks for update.

     

    Seems we have to start troubleshoot the root cause that that why DHCP doesn't leases addresses for clients even the scope is not fully used .

     

    Could you discuss in detail that How you set DHCP scope for wireless VLAN ? and have you deployed DHCP relay ?

     

    You may try the methods that listed in the article below:

     

    “The DHCP server fails to issue address leases for a new scope” paragraph of Troubleshooting DHCP Servers

    http://technet.microsoft.com/en-us/library/cc958946.aspx

     

    Meanwhile, I’d suggest you may take look the introduction of DHCP Lease Process and capture network traffic form client when fail acquire address form DHCP for advance troubleshooting .

     

    DHCP Lease Process

    http://technet.microsoft.com/en-us/library/cc958908.aspx

     

    Microsoft Network Monitor 3.4

    http://www.microsoft.com/downloads/en/details.aspx?FamilyID=983b941d-06cb-4658-b7f6-3088333d062f&displaylang=en

     

    Thanks.

     

    Tiger Li


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    Wednesday, December 15, 2010 7:46 AM