none
Query DHCP using script

    Question

  • Hi there

    how can i produce a list of MAC addresses that are registered in a single DHCP scope using a script?
    Also how can I filter this list to leave an output of MAC addresses that begin with 00:11 for example?

    Many thanks in advance!
    Shane
    Wednesday, June 24, 2009 8:39 AM

Answers

  • Did you run the command on the dhcp server?
    What Operating System is your DHCP server running?

    You may need to run netsh add helper dhcpmon.dll first.
    • Edited by perhof Wednesday, June 24, 2009 11:24 AM dhcpmon.dll
    • Marked as answer by Shay LeviModerator Sunday, June 28, 2009 8:50 AM
    Wednesday, June 24, 2009 11:17 AM

All replies

  • This command will list all leases for a certain scope if you run it on the DHCP server:
    netsh dhcp server scope 192.168.1.0 show clients
    You can pipe the output of the command to a text file if you want to and then process the file manually in an editor or you can write a script that parses the output from the netsh command to produce a custom list automatically but that will require some work.
    How often will you need to produce lists like this?
    • Edited by perhof Wednesday, June 24, 2009 9:14 AM
    • Proposed as answer by perhof Wednesday, June 24, 2009 1:31 PM
    Wednesday, June 24, 2009 9:12 AM
  • Thanks for your quick reposnse perhof!
    I want to run the script once per week to check for rogue clients on the network.
    When I run the command above i get the error:
    "The following command was not found: dhcp server scope x.x.x.x show clients."

    Thanks!
    Wednesday, June 24, 2009 10:30 AM
  • Did you run the command on the dhcp server?
    What Operating System is your DHCP server running?

    You may need to run netsh add helper dhcpmon.dll first.
    • Edited by perhof Wednesday, June 24, 2009 11:24 AM dhcpmon.dll
    • Marked as answer by Shay LeviModerator Sunday, June 28, 2009 8:50 AM
    Wednesday, June 24, 2009 11:17 AM
  • Working now!
    Thanks for your help!
    Shane
    Wednesday, June 24, 2009 11:58 AM