Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: MAC Address and NIC Device on Network.

by vladdrak (Monk)
on Jun 27, 2001 at 05:27 UTC ( #91807=note: print w/ replies, xml ) Need Help??


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


Comment on Re: MAC Address and NIC Device on Network.
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://91807]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (14)
As of 2015-07-31 12:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (277 votes), past polls