Last active
April 10, 2025 05:44
-
-
Save rmtbb/b9ecd7201c7caf925cd60be88cb43ffb to your computer and use it in GitHub Desktop.
whereyallfrom by Remote BB - A handy ZSH command to look up MAC address vendors on your network — or any list of MACs you throw at it.
This file contains hidden or 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
function whereyallfrom() { | |
OUI_FILE="$HOME/oui.txt" | |
if [[ ! -f "$OUI_FILE" ]]; then | |
echo "Error: $OUI_FILE not found!" | |
return 1 | |
fi | |
clean_mac() { | |
echo "$1" | tr -d ':-.' | tr '[:lower:]' '[:upper:]' | |
} | |
lookup_mac() { | |
local mac="$1" | |
local ip="$2" | |
local cleaned=$(clean_mac "$mac") | |
local oui=${cleaned:0:6} | |
if [[ "$oui" == "FFFFFF" ]]; then | |
echo "$ip | $mac | <broadcast>" | |
return | |
fi | |
# Grab vendor line from (base 16) entries | |
vendor=$(grep -i "^$oui" "$OUI_FILE" | grep "(base 16)" | awk -F'\t' '{print $2}' | sed 's/^ *//;s/ *$//' | head -n 1) | |
if [[ -z "$vendor" ]]; then | |
echo "$ip | $mac | No vendor found" | |
else | |
echo "$ip | $mac | $vendor" | |
fi | |
} | |
# Print header | |
printf "%-16s | %-17s | %-30s\n" "IP Address" "MAC Address" "Vendor" | |
printf "%-16s-+-%-17s-+-%-30s\n" "----------------" "-----------------" "------------------------------" | |
if [ $# -eq 0 ]; then | |
# Parse arp -a output: grab IP and MAC pairs | |
arp -a | awk '/at/ {print $2, $4}' | sed 's/[()]//g' | while read -r ip mac; do | |
lookup_mac "$mac" "$ip" | |
done | |
else | |
for mac in "$@"; do | |
lookup_mac "$mac" "-" | |
done | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
whereyallfrom by Remote BB
A handy ZSH command to look up MAC address vendors on your network — or any list of MACs you throw at it.
🚀 What it Does
arp -a
) for devicesoui.txt
) to determine vendor🛠️ Setup
1. Download the OUI Database
Download the latest vendor list from the IEEE directly:
🔗 https://standards-oui.ieee.org/oui/oui.txt
Save the file as:
This script expects it to be located at:
$HOME/oui.txt
2. Add the function to your
~/.zshrc
Open your shell config:
nano ~/.zshrc
Paste the following function at the bottom:
To save and exit Nano:
Control + X
Y
to confirmEnter
to save and close3. Reload your shell
🧪 Usage
✅ Example Output
💡 Notes
oui.txt
to be downloaded from IEEE and placed in$HOME
Made with ❤️ by Remote BB
For the nosy network nerd in all of us.