Skip to content

Instantly share code, notes, and snippets.

@raspi
Created March 16, 2021 22:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raspi/7c02b787d3c04d7da515a241ed2857c0 to your computer and use it in GitHub Desktop.
Save raspi/7c02b787d3c04d7da515a241ed2857c0 to your computer and use it in GitHub Desktop.
Get vendors from `/proc/net/arp` with systemd's OUI vendor database
#!/bin/bash
# Get vendors from /proc/net/arp with systemd's OUI vendor database
set -eu
set -o pipefail
OUIDB=/usr/lib/udev/hwdb.d/20-OUI.hwdb
while IFS=$' ' read -r ipaddr htype flags mac mask iface;
do
vendormac=${mac::8}
vendormac=${vendormac//:}
vendor=$( grep -A 1 -i "^OUI:$vendormac" $OUIDB | tail -1 | cut -d'=' -f2- || echo "UNKNOWN")
echo -e "$iface\t$mac\t$ipaddr\t$vendor"
done <<< $(tail -n +2 < /proc/net/arp)
@raspi
Copy link
Author

raspi commented Mar 16, 2021

Example output (censored):

phy0 00:25:90:XX:XX:XX 192.168.XXX.XXX Super Micro Computer, Inc.
phy0 00:00:00:XX:XX:XX 192.168.XXX.XXX XEROX CORPORATION
phy0 00:30:18:XX:XX:XX 192.168.XXX.XXX Jetway Information Co., Ltd.
phy0 00:00:00:XX:XX:XX 192.168.XXX.XXX XEROX CORPORATION

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment