Solved

Script to resolve MAC address to Vendor list

Posted on 2004-04-29
4
4,183 Views
Last Modified: 2010-08-05
Hello, I have a list of 6000 mac address. I have downloaded the oui.txt file from IEEE of the vendors. I would like to run the 6000 mac address against the oui.txt. What would be th best way to go ?
I have tries to sort them and get the names of the Vendors. I would like to just get the counts/persentage of the vendor mac for a pie chart. The Mac addr are the wireless card used in our enterprise. To draw the pie chart I have a php script.

http://standards.ieee.org/regauth/oui/oui.txt it looks like this..
00-00-00   (hex)            XEROX CORPORATION
000000     (base 16)            XEROX CORPORATION
                        M/S 105-50C
                        800 PHILLIPS ROAD
                        WEBSTER NY 14580

00-00-01   (hex)            XEROX CORPORATION
000001     (base 16)            XEROX CORPORATION
                        ZEROX SYSTEMS INSTITUTE
                        M/S 105-50C 800 PHILLIPS ROAD
                        WEBSTER NY 14580
---------------------------------------------------------------------------------------
my mac addr .txt file looks like this..
00e098a32b78
00e098a32bd0
00e098a34b4c
00e098a34c4c
00e098a34c5a
00e098a35d68
00e098a36598
...
---------------------

Thanks in advance.
0
Comment
Question by:amitubale
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 7

Expert Comment

by:fim32
ID: 10952166
well, as you can see, the vendor string is the first 6 hex digits... so i would go through your mac list and organize them by the first 6 digits, and count those.  then it'll be a lot easier to compare them against the oui.txt list.

in fact, i'm sure you'll reduce yourself to a handful of vendors...
0
 
LVL 10

Accepted Solution

by:
Mercantilum earned 50 total points
ID: 10958146
Maybe something like

use strict;

my %mac;

# get mac data
open F, "mac.txt" or die "mac.txt: $!";
while (<F>) { $mac{lc(substr($_,0,6))}++; }
close F;

my %oui;

# get oui data
open F, "oui.txt" or die "oui.txt: $!";
while (<F>)
{
  if (/^[0-9a-f][0-9a-f]-[0-9a-f][0-9a-f]-[0-9a-f][0-9a-f]/i)
  {
     chomp;
     @_ = split /[()]/;
     $_[0] =~ s/-//g;
     $_[2] =~ s/^[\t\s]+//;
     $oui{lc(substr($_[0], 0, 6))} = $_[2];
  }
}
close F;

# print list of mac sorted
for (sort { $mac{$a} <=> $mac{$b} } keys %mac)
{
   my $vendor = (exists $oui{$_} ? $oui{$_}:"???");
   print "Mac: $_ Vendor: $vendor Number: $mac{$_}\n";
}
0
 
LVL 1

Author Comment

by:amitubale
ID: 10962502
Hello Mercantilum
Thank you for the soution, I hardly know any perl but I wrote 4 different scripts to do various functions on my mac address list. You solution is perfect for what I am trying to do. FYI the list of MAC are all the wireless users in our enterprise ..not i will dig out a php script to chart a nice pie chart on a web server.

Thank you.
Amit

I also found another one http://net.doit.wisc.edu/~plonka/mac2vendor/

0
 
LVL 10

Expert Comment

by:Mercantilum
ID: 10962536
My pleasure :)
Interesting file Mac / vendors.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question