Recipe14.10.Managing the Leases for a Scope


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

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



Windows Server Cookbook
Windows Server Cookbook for Windows Server 2003 and Windows 2000
ISBN: 0596006330
EAN: 2147483647
Year: 2006
Pages: 380
Authors: Robbie Allen

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net