• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4565
  • Last Modified:

Script to resolve MAC address to Vendor list

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..

Thanks in advance.
  • 2
1 Solution
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...
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)
     @_ = 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";
amitubaleAuthor Commented:
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.

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

My pleasure :)
Interesting file Mac / vendors.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now