A script to run a quick network device inventory

Oct 13, '04 09:45:00AM

Contributed by: MartySells

I've written a script that I call netinv which uses the ARP cache to identify devices on the network segment. For each device, it looks up the vendor name based on the MAC address and also tries to get the remote system's netbios name. For small (i.e. home) networks, the vendor and netbios name are usually enough to remind you what a particular device is.

To use it, start by downloading the script from my page; you can do this in the Terminal by typing:

  curl -O 'http://www.studiosells.net/msells/netinv'
Once downloaded, move it to a directory on your path and make it executable with chmod a+rx ./netinv (assuming you're in that directory). Read the rest of the hint for some sample output and further explanations on how the tool works.

Sample Output:

$ ./netinv
IP               MAC                    DNSname         NBname          Vendor          
----------       ----------             ----------      ----------      ----------      
192.168.3.1      0:a0:c5:e2:4a:16       ?                               ZYXEL COMMUNICATION
192.168.3.3      0:0:39:8:4:1a          ?               PIZZA           TOSHIBA CORPORATION
192.168.3.4      0:4:e2:52:4e:11        dell            CANADA          SMC Networks, Inc.
192.168.3.40     0:50:e4:99:2c:39       meatloaf        MEATLOAF        APPLE COMPUTER, INC.
192.168.3.52     0:b:db:a7:4c:5         ?               STACY           Dell ESG PCBA Test
192.168.3.60     0:4:76:da:47:1d        dell            DELL            3 Com Corporation
192.168.0.110    00:03:93:bf:17:c0      eyeBook         EYEBOOK         Apple Computer, Inc.
192.168.3.200    0:3:93:bd:26:1e        fatmac          FATMAC          Apple Computer, Inc.
Notes:
  1. Since this works from your ARP table it will only include hosts that you've ARPed for:

  2. There are command line options to disable the vendor and netbios lookups, as well as to produce non-justified tab separated output without the header. See netinv -h for details.

  3. If you don't have the Perl module Net::MAC::Vendor, then netinv will use a built-in vendor lookup that seems to work OK, but is probably not as robust. Try installing the module with perl -MCPAN -e 'install Net::MAC::Vendor'. There's also a web page where you can do MAC-to-vendor lookups.

Comments (22)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20041010213347605