Recipe 14.10. Managing the Leases for a ScopeProblemYou want to view or delete the active leases for a scope. SolutionUsing a graphical user interface
Using a command-line interfaceThe following command displays the allocated leases for scope 10.1.2.0: > netsh dhcp server scope 10.1.2.0 show clients The following command deletes the lease for IP address 10.1.2.5: > netsh dhcp server scope 10.1.2.0 delete lease 10.1.2.5 Using VBScriptSee Recipe 14.0 for more information on how to run the netsh command from within a script. DiscussionIf you delete a lease, you'll also need to make sure the client isn't actively using that IP address anymore. Simply deleting the lease on the DHCP Server makes that lease available again for other clients to use. It doesn't actually do anything to the client itself. You can release a lease on the client by running ipconfig /release. Then run ipconfig /renew to request a new lease. The netsh command supports a few other options for deleting leases. Instead of specifying the lease IP address, you can instead specify a hostname. The following command deletes the lease associated with the host rallen-wxp in the scope 10.1.2.0: > netsh dhcp server scope 10.1.2.0 delete lease \\rallen-wxp If there are multiple leases that have been allocated to rallen-wxp, only the first one will be deleted. You can also delete all leases marked as BAD_ADDRESS (which indicates the server attempted to assign the lease IP, but some other device is using that address). The following command deletes all BAD_ADDRESS leases: > netsh dhcp server scope 10.1.2.0 delete lease allbadaddresses Finally, you can delete all leases obtained by a RAS server using the following command: > netsh dhcp server scope 10.1.2.0 delete lease allrasserveraddresses |