]> git.slaskete.net - einar-bin/blob - macvendor.sh
Kjapt lite MAC-vendor-oppslagscript
[einar-bin] / macvendor.sh
1 #!/usr/bin/env bash
2
3 prefixesfile=/home/einar/ownCloud/Datadumper/master_oui.txt
4
5 if [[ ! -f $prefixesfile ]]; then
6 echo "Could not find MAC prefixes file $prefixesfile, please download from https://raw.githubusercontent.com/Ringmast4r/OUI-Master-Database/main/LISTS/master_oui.txt and save to some suitable "
7 exit 1
8 fi
9
10 hexregex="^[[:xdigit:]]{6,12}$"
11
12 prefix=${1//:/} # strip :
13 prefix=${prefix//-/} # strip -
14 prefix=${prefix//./} # strip .
15 prefix=${prefix^^} # uppercase
16
17 if [[ $prefix =~ $hexregex ]]; then
18 prefix=${prefix:0:6} # we only need first 6 chars
19 grep "$prefix" "$prefixesfile"
20 else
21 echo "Input parameter does not resemble a MAC address"
22 exit 1
23 fi