- Saved searches
- Use saved searches to filter your results more quickly
- License
- bevry/getmac
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- About
- node-macaddress
- Usage
- API + Examples
- .one([iface], callback)
- .all(callback)
- .networkInterfaces()
- Saved searches
- Use saved searches to filter your results more quickly
- License
- scravy/node-macaddress
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- About
- getmac
- Usage
- CLI
- API
- Advanced
- Install
- npm
- Editions
- History
- Contribute
- Backers
- Maintainers
- Sponsors
- Contributors
- License
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
Get the mac address of the current machine you are on via Node.js
License
bevry/getmac
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
Get the MAC address of the current machine you are on.
This library will not run in web browsers / on the client-side / in webpack / in browserify / in angular / in react / in jQuery / in HTML. It will only run on Node.js environments, which the web browser is not.
Install globally npm install -g getmac , then run with getmac-node
Install locally npm install —save getmac , then use like so:
import getMAC, isMAC > from 'getmac' // Fetch the computer's MAC address console.log(getMAC()) // Fetch the computer's MAC address for a specific interface console.log(getMAC('eth0')) // Validate that an address is a MAC address if (isMAC('e4:ce:8f:5b:a7:fc')) console.log('valid MAC') > else console.log('invalid MAC') >
If you want to do advanced filtering, use os.networkInterfaces() instead.
- Install: npm install —save getmac
- Import: import pkg from (‘getmac’)
- Require: const pkg = require(‘getmac’).default
import pkg from 'https://unpkg.com/getmac@^5.20.0/edition-deno/index.ts'
This package is published with the following editions:
- getmac/source/index.ts is TypeScript source code with Import for modules
- getmac aliases getmac/edition-es2019/index.js
- getmac/edition-es2019/index.js is TypeScript compiled against ES2019 for Node.js 10 || 12 || 14 || 16 with Require for modules
- getmac/edition-es2019-esm/index.js is TypeScript compiled against ES2019 for Node.js 12 || 14 || 16 with Import for modules
- getmac/edition-deno/index.ts is TypeScript source code made to be compatible with Deno
These amazing people are maintaining this project:
No sponsors yet! Will you be the first?
These amazing people have contributed code to this project:
Unless stated otherwise all works are:
About
Get the mac address of the current machine you are on via Node.js
node-macaddress
Retrieve MAC addresses in Linux, OS X, and Windows.
A common misconception about MAC addresses is that every host had one MAC address, while a host may have multiple MAC addresses – since every network interface may have its own MAC address.
This library allows to discover the MAC address per network interface and chooses an appropriate interface if all you’re interested in is one MAC address identifying the host system (see API + Examples below).
A common misconception about this library is that it reports the mac address of the client that accesses some kind of backend. It does not. Reporting the mac address is not in any way similar to reporting the IP address of the client that accesses your application. This library reports the mac address of the server the application is running on. This useful for example for distributed/scaled applications, for example when generating UUIDs.
Also it seems to be worth noting that this library is not intended to be used in a browser. There is no web api reporting the mac address of the machine (and that is a good thing).
- works on Linux , Mac OS X , Windows , and on most UNIX systems.
- node ≥ 0.12 and io.js report MAC addresses in os.networkInterfaces() this library utilizes this information when available.
- also features a sane replacement for os.networkInterfaces() (see API + Examples below).
- works with stoneage node versions ≥ v0.8 (. )
- Promise support
Usage
npm install --save macaddress
var macaddress = require('macaddress');
API + Examples
(async) .one(iface, callback) → string (async) .one(iface) → Promise (async) .one(callback) → string (async) .all() → Promise >> (async) .all(callback) → < iface: < type: address >> (sync) .networkInterfaces() → < iface: < type: address >>
.one([iface], callback)
Retrieves the MAC address of the given iface .
If iface is omitted, this function automatically chooses an appropriate device (e.g. eth0 in Linux, en0 in OS X, etc.).
Without iface parameter:
macaddress.one(function (err, mac) console.log("Mac address for this host: %s", mac); >);
macaddress.one().then(function (mac) console.log("Mac address for this host: %s", mac); >);
→ Mac address for this host: ab:42:de:13:ef:37
With iface parameter:
macaddress.one('awdl0', function (err, mac) console.log("Mac address for awdl0: %s", mac); >);
macaddress.one('awdl0').then(function (mac) console.log("Mac address for awdl0: %s", mac); >);
→ Mac address for awdl0: ab:cd:ef:34:12:56
.all(callback)
Retrieves the MAC addresses for all non-internal interfaces.
macaddress.all(function (err, all) console.log(JSON.stringify(all, null, 2)); >);
macaddress.all().then(function (all) console.log(JSON.stringify(all, null, 2)); >);
"en0": "ipv6": "fe80::cae0:ebff:fe14:1da9", "ipv4": "192.168.178.20", "mac": "ab:42:de:13:ef:37" >, "awdl0": "ipv6": "fe80::58b9:daff:fea9:23a9", "mac": "ab:cd:ef:34:12:56" > >
.networkInterfaces()
A useful replacement of os.networkInterfaces() . Reports only non-internal interfaces.
console.log(JSON.stringify(macaddress.networkInterfaces(), null, 2));
"en0": "ipv6": "fe80::cae0:ebff:fe14:1dab", "ipv4": "192.168.178.22" >, "awdl0": "ipv6": "fe80::58b9:daff:fea9:23a9" > >
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
Get the MAC addresses (hardware addresses) of the hosts network interfaces.
License
scravy/node-macaddress
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
Retrieve MAC addresses in Linux, OS X, and Windows.
A common misconception about MAC addresses is that every host had one MAC address, while a host may have multiple MAC addresses – since every network interface may have its own MAC address.
This library allows to discover the MAC address per network interface and chooses an appropriate interface if all you’re interested in is one MAC address identifying the host system (see API + Examples below).
A common misconception about this library is that it reports the mac address of the client that accesses some kind of backend. It does not. Reporting the mac address is not in any way similar to reporting the IP address of the client that accesses your application. This library reports the mac address of the server the application is running on. This useful for example for distributed/scaled applications, for example when generating UUIDs.
Also it seems to be worth noting that this library is not intended to be used in a browser. There is no web api reporting the mac address of the machine (and that is a good thing).
- works on Linux , Mac OS X , Windows , and on most UNIX systems.
- node ≥ 0.12 and io.js report MAC addresses in os.networkInterfaces() this library utilizes this information when available.
- also features a sane replacement for os.networkInterfaces() (see API + Examples below).
- works with stoneage node versions ≥ v0.8 (. )
- Promise support
npm install --save macaddress
var macaddress = require('macaddress');
(async) .one(iface, callback) → string (async) .one(iface) → Promise (async) .one(callback) → string (async) .all() → Promise >> (async) .all(callback) → < iface: < type: address >> (sync) .networkInterfaces() → < iface: < type: address >>
Retrieves the MAC address of the given iface .
If iface is omitted, this function automatically chooses an appropriate device (e.g. eth0 in Linux, en0 in OS X, etc.).
Without iface parameter:
macaddress.one(function (err, mac) console.log("Mac address for this host: %s", mac); >);
macaddress.one().then(function (mac) console.log("Mac address for this host: %s", mac); >);
→ Mac address for this host: ab:42:de:13:ef:37
With iface parameter:
macaddress.one('awdl0', function (err, mac) console.log("Mac address for awdl0: %s", mac); >);
macaddress.one('awdl0').then(function (mac) console.log("Mac address for awdl0: %s", mac); >);
→ Mac address for awdl0: ab:cd:ef:34:12:56
Retrieves the MAC addresses for all non-internal interfaces.
macaddress.all(function (err, all) console.log(JSON.stringify(all, null, 2)); >);
macaddress.all().then(function (all) console.log(JSON.stringify(all, null, 2)); >);
"en0": "ipv6": "fe80::cae0:ebff:fe14:1da9", "ipv4": "192.168.178.20", "mac": "ab:42:de:13:ef:37" >, "awdl0": "ipv6": "fe80::58b9:daff:fea9:23a9", "mac": "ab:cd:ef:34:12:56" > >
A useful replacement of os.networkInterfaces() . Reports only non-internal interfaces.
console.log(JSON.stringify(macaddress.networkInterfaces(), null, 2));
"en0": "ipv6": "fe80::cae0:ebff:fe14:1dab", "ipv4": "192.168.178.22" >, "awdl0": "ipv6": "fe80::58b9:daff:fea9:23a9" > >
About
Get the MAC addresses (hardware addresses) of the hosts network interfaces.
getmac
Get the MAC address of the current machine you are on.
This library will not run in web browsers / on the client-side / in webpack / in browserify / in angular / in react / in jQuery / in HTML. It will only run on Node.js environments, which the web browser is not.
Usage
CLI
Install globally npm install -g getmac , then run with getmac-node
API
Install locally npm install —save getmac , then use like so:
import getMAC, isMAC > from 'getmac' // Fetch the computer's MAC address console.log(getMAC()) // Fetch the computer's MAC address for a specific interface console.log(getMAC('eth0')) // Validate that an address is a MAC address if (isMAC('e4:ce:8f:5b:a7:fc')) console.log('valid MAC') > else console.log('invalid MAC') >
Advanced
If you want to do advanced filtering, use os.networkInterfaces() instead.
Install
npm
- Install: npm install —save getmac
- Import: import pkg from (‘getmac’)
- Require: const pkg = require(‘getmac’).default
Editions
This package is published with the following editions:
- getmac/source/index.ts is TypeScript source code with Import for modules
- getmac aliases getmac/edition-es2019/index.js
- getmac/edition-es2019/index.js is TypeScript compiled against ES2019 for Node.js 10 || 12 || 14 || 16 with Require for modules
- getmac/edition-es2019-esm/index.js is TypeScript compiled against ES2019 for Node.js 12 || 14 || 16 with Import for modules
History
Contribute
Backers
Maintainers
These amazing people are maintaining this project:
Sponsors
No sponsors yet! Will you be the first?
Contributors
These amazing people have contributed code to this project:
License
Unless stated otherwise all works are: