14.10. Managing the Leases for a Scope

Problem

You want to view or delete the active leases for a scope.

Solution

Using a graphical user interface

  1. Open the DHCP snap-in.

  2. In the left pane, right-click on DHCP and select Add Server.

  3. Type in the name of the DHCP Server you want to target and click OK.

  4. Expand the target scope.

  5. Click on Address Leases. The list of allocated leases will be displayed in the right pane.

  6. To delete a lease, right-click the target lease in the right pane and select Delete.

  7. Confirm the deletion by selecting Yes.

Tip

If you are interested in scope utilization, you can view the statistics on a per-scope basis by right-clicking the scope and selecting Display Statistics.

Using a command-line interface

The 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 VBScript

See Recipe 14.0 for more information on how to run the netsh command from within a script.

Discussion

If 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 ...

Get Windows Server Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.