how to log the MAC addresses of devices acquiring an IP address through DHCP (Windows server 2022)
My network serves DHCP through a Windows 2022 server. I would like to log the MAC addresses of all devices that acquire an IP address through this DHCP server. I have installed the IPAM role in the server, but I don't understand how to activate the logging. The server is standalone; it does not use Active Directory and it's not connected to a domain.
Solution 1:
Get-DhcpServerv4Lease -ComputerName "dhcpserver.contoso.com" -ScopeId 10.10.10.0
Powershell can do this for you.
Get-DhcpServerv4Lease -ComputerName <MyDHCP> -ScopeId 192.168.0.0
In the output of this function, you will find the MAC address of the clients and the status of the leases as additional information.
This is for real time information.
You can view the logs of past events (once audit logging is enabled) via these steps:
To enable enhanced DHCP logging, perform the following steps:
- Start the DHCP administration tool (go to Start, Programs, Administrative Tools, and click DHCP).
- Right-click the DHCP server, and select Properties from the context menu.
- Select the General tab.
- Select the "Enable DHCP audit logging" check box
Lots of good information on DHCP audit logs here.