https://github.com/foxt/mac-oui
Small library to parse a MAC address and retrieve data from the IEEE OUI DB.
https://github.com/foxt/mac-oui
Last synced: 5 months ago
JSON representation
Small library to parse a MAC address and retrieve data from the IEEE OUI DB.
- Host: GitHub
- URL: https://github.com/foxt/mac-oui
- Owner: foxt
- License: mit
- Created: 2024-05-22T18:55:00.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-22T19:06:59.000Z (about 2 years ago)
- Last Synced: 2025-03-19T15:01:57.687Z (about 1 year ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/oui-mac/v/1.0.0-readme3
- Size: 7.81 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
```js
const MAC = require("oui-mac");
const fs = require("fs");
```
or
```ts
import * as MAC from "oui-mac";
import * as fs from "fs";
```
then
```js
// Download it from https://standards-oui.ieee.org/oui/oui.txt
const ouitxt = fs.readFileSync("oui.txt", "utf8");
const OUIDb = MAC.OUIDb(ouitxt);
console.log("Read", OUIDb.size, "OUIs from the database");
function printMac(mac) {
console.log(`${mac}:`);
let parsed = MAC.parse(mac);
console.log(` - Normalised: ${MAC.toString(parsed)}`);
console.log(` - OUI: ${MAC.getOui(parsed)}`);
console.log(` - Multicast: ${MAC.getMulticast(parsed)}`);
console.log(` - LAA: ${MAC.getLAA(parsed)}`);
console.log(` - Docker: ${MAC.isDocker(parsed) ? "Likely" : "Unlikely"} (converted to IP: ${MAC.dockerIP(parsed)})`);
let vendor = MAC.getVendor(parsed, OUIDb);
if (vendor) {
console.log(` - Vendor: ${vendor.name}`);
console.log(` ${vendor.address}`);
console.log(` ${vendor.region}`);
console.log(` ${vendor.country}`);
}
}
printMac("bc:24:11:cf:9a:4b")
```