]> git.slaskete.net - einar-bin/commitdiff
Kjapt lite MAC-vendor-oppslagscript
authorEinar Jørgen Haraldseid <einar@haraldseid.net>
Sat, 18 Apr 2026 10:05:05 +0000 (12:05 +0200)
committerEinar Jørgen Haraldseid <einar@haraldseid.net>
Sat, 18 Apr 2026 10:05:05 +0000 (12:05 +0200)
macvendor.sh [new file with mode: 0755]

diff --git a/macvendor.sh b/macvendor.sh
new file mode 100755 (executable)
index 0000000..c4dd1b2
--- /dev/null
@@ -0,0 +1,23 @@
+#!/usr/bin/env bash
+
+prefixesfile=/home/einar/ownCloud/Datadumper/master_oui.txt
+
+if [[ ! -f $prefixesfile ]]; then
+  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 "
+  exit 1
+fi
+
+hexregex="^[[:xdigit:]]{6,12}$"
+
+prefix=${1//:/}      # strip :
+prefix=${prefix//-/} # strip -
+prefix=${prefix//./} # strip .
+prefix=${prefix^^}   # uppercase
+
+if [[ $prefix =~ $hexregex ]]; then
+  prefix=${prefix:0:6} # we only need first 6 chars
+  grep "$prefix" "$prefixesfile"
+else
+  echo "Input parameter does not resemble a MAC address"
+  exit 1
+fi