Powershell-过滤IP对应MAC或主机名

需求:

安全同事新需求,想通过IP地址及时溯源出MAC或主机名信息;

环境:

Windows Server 2016 + DHCP

分析:

记得之前写过一篇"Powershell-过滤MAC地址对应IP地址信息"文章;

通过相同原理可实现MAC与主机名信息过滤;

步骤:

1.相关DHCP服务器命令选择:

Get-DhcpServerv4Lease :

从动态主机配置协议(DHCP)服务器服务获取一个或多个租约记录。

GET-DhcpServerv4Scope :

返回指定范围的IPv4范围配置。如果未指定ScopeId参数,则返回动态主机配置协议(DHCP)服务器服务上配置的所有范围。

  • Get-DhcpServerv4Lease[-ComputerName <String>]-IPAddress <IPAddress[]>[-CimSession <CimSession[]>][-ThrottleLimit <Int32>][-AsJob][<CommonParameters>]Get-DhcpServerv4Lease[-ComputerName <String>][-ScopeId] <IPAddress>[-ClientId] <String[]>[-CimSession <CimSession[]>][-ThrottleLimit <Int32>][-AsJob][<CommonParameters>]Get-DhcpServerv4Lease[-ComputerName <String>][-BadLeases][[-ScopeId] <IPAddress>][-CimSession <CimSession[]>][-ThrottleLimit <Int32>][-AsJob][<CommonParameters>]
    2.查询所有作用域下的租约信息,并过滤IP地址对应MAC及主机名信息:
  • Get-DhcpServerv4Scope |Get-DhcpServerv4Lease |where {$_.IPAddress -like "10.18.133.27"}
    640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1



640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1


猜你喜欢

转载自blog.51cto.com/wenzhongxiang/2439460