http://www.perlmonks.org?node_id=91807


in reply to MAC Address and NIC Device on Network.

There is a Resource Kit utility called getmac.exe that can prove useful. You'll want to either compile a list of the machines you want to check, or enumerate an NT domain to check those machines. You could also walk IP addresses if you don't have a network browse list built up. Anyways, your code might be:
my @machines=("host1","host2","host3"); my %macs=(); for my $machine (@machines) { my $macraw=`getmac $machine`; if ($macraw =~ /(match something)/) { $macs{$1}=$machine; } } print "$macs{$_} $_\n" for (keys %macs);
Which would fill $macraw with something like this:
Transport Address Transport Name ----------------- -------------- 00-00-00-00-00-00 \Device\NetbiosSmb 00-A0-B0-6C-38-D0 \Device\NetBT_El90x1
..which you'll clean up with the regex buffer, and then toss it in a hash. The NetBT_El90x just identifies the interface as a 3Com 9xx card. Intels show as E100b, Compaq NetFlex as NetFlx, etc. In Win2k the identifer is actually a GUID that maps back to the driver/service name (joy!). If you have a good idea of what NICs are on your LAN it makes it easier.. you'll probably want to do a dirty scan first on everything, then refine your regex.

Good Luck,
Vlad