如何检查dhcp IP何时发布?

问题描述 投票:-1回答:1

我的DHCP服务器是2008R2。我想知道如果有任何方法可以知道给定DHCP IP地址的发布日期和时间?

我看到有一个命令“get-dhcpserverv4lease”,但它只存在于Win 10和Server 2016上。

我如何在2008R2或2012R2上了解它?

powershell dhcp
1个回答
1
投票

您可以使用WMI oder netsh。

DMH

Get-WmiObject -Namespace ROOT\Microsoft\Windows\DHCP -List | Where-Object Name -eq 'DhcpServerv4Lease'

不幸的是,我无法验证此WMI查询,因为我只有一台Windows Server 2016 DHCP服务器,并且它返回一个空对象。然而,PS_DhcpServerv4IPLease类在2016年正常运作。

NETSH

您需要解析输出并遍历所有范围

netsh dhcp server \\dhcpservername show scope

==============================================================================
 Scope Address  - Subnet Mask    - State        - Scope Name          -  Comment
==============================================================================

 192.168.178.0  - 255.255.255.0  -Active        -Default IPv4 Scope   -

 Total No. of Scopes = 1
Command completed successfully.

然后通过所有IP地址

C:\Windows\system32>netsh dhcp server \\dhcpservername scope 192.168.178.0 show clients

Changed the current scope context to 192.168.178.0 scope.

Type : N - NONE, D - DHCP B - BOOTP, U - UNSPECIFIED, R - RESERVATION IP
==================================================================================
IP Address      - Subnet Mask    - Unique ID           - Lease Expires        -Type
==================================================================================

192.168.178.170 - 255.255.255.0  - b0-72-bf-cb-97-a0   -25.04.2019 18:56:41    -D
192.168.178.171 - 255.255.255.0  - 00-0d-2f-d5-b1-d6   -25.04.2019 12:03:38    -D
192.168.178.172 - 255.255.255.0  - b0-4e-26-72-9b-5f   -19.04.2019 23:08:19    -D
192.168.178.173 - 255.255.255.0  - 70-4f-57-11-01-03   -20.04.2019 23:00:00    -D

No of Clients(version 4): 4 in the Scope : 192.168.178.0.

Command completed successfully.
© www.soinside.com 2019 - 2024. All rights reserved.