1

The follow is on MacOS High Sierra with Perl v5.28.2. The version of Net::MAC::Vendor is 1.265. This sort of a repeat post. My prior post lacked a lot of detail.

I am trying to put together a script to list ip addresses, MAC addresses, and vendors on a network. The Net::MAC::Vendor::lookup function is returning a timeout error amongst other things. I have checked a few IEEE links that were supposed to have the OUI data but they are all dead returning no data. I have seen a number of mentions stating the file can be found in some installations of linux. I have search high and low and have not found an oui.txt file on my system. If I downloaded a copy I wouldn't know where to put it or how I could have the Net::MAC::Vendor function to locate it. Also, if I did find a link I still wouldn't know how to direct the vendor lookup function to use it.

The errors I am getting are as follows:

Use of uninitialized value in concatenation (.) or string at /Users/{username}/perl5/perlbrew/perls/perl-5.28.2/lib/site_perl/5.28.2/Net/MAC/Vendor.pm line 320. Failed fetching [https://services13.ieee.org/RST/standards-ra-web/rest/assignments/download/?registry=MA-L&format=html&text=D8-D7-75] HTTP status [] message [Connect timeout] at simplemacvendor.pl line 23. Could not fetch data from the IEEE! at simplemacvendor.pl line 23.

The sample code:

    #!/usr/bin/perl;
    use strict;
    use feature qw(say);
    use Data::Dumper qw(Dumper);
    use Net::MAC::Vendor;

    open(ARP, "arp -na|") || die "Failed $!\n";
    my @arp_table;
    while (<ARP>) {
        if ($_ =~ m/incomplet/) {next;}
        if ($_ =~ m/Address/) {next;}
        my @line = split(' ',$_);
        my $computer = {};

        $line[1] =~ s/(\()([0-9\.]*)(\))/\2/;
        $computer->{ip} = $line[1];
        $computer->{mac}  = $line[3];
        $computer->{if}  = $line[5];

        say Dumper($computer);

    # Get vendor info
        my $vendor_info = Net::MAC::Vendor::lookup( $computer->{mac} ); # line 23
        $computer->{vendor} = $vendor_info->[0];
        push @arp_table , $computer;
    }

    print "ARP Table with vendors:\n";
    for my $i (0 .. $#arp_table) {
        print "$arp_table[$i]{ip}\t";
        print "$arp_table[$i]{if}\t";
        print "$arp_table[$i]{mac}\t";
        print "$arp_table[$i]{vendor}";
        print "\n";
    }
2
  • According to the documentation, you can set the environment variable NET_MAC_VENDOR_OUI_URL to try a new url for the OUI file. Have you tried that? Commented May 7, 2020 at 14:54
  • I have not found a site yet. I came across one site that listed a number of urls but allow were down. Would the variable work for local files?
    – Coltrane58
    Commented May 7, 2020 at 15:26

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.