Created
March 16, 2021 22:18
-
-
Save raspi/7c02b787d3c04d7da515a241ed2857c0 to your computer and use it in GitHub Desktop.
Get vendors from `/proc/net/arp` with systemd's OUI vendor database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example output (censored):