Search code examples
javascriptnode.jsmac-address

Get the MAC address i'm using to connect to internet, in nodejs?


I'm using macaddress, but I don't know how to get the mac address what I'm using to connect to the internet

const macaddress = require('macaddress');

macaddress.all(function (err, all) {
  console.log("Your mac address is -->" + JSON.stringify(all, null, 2));
});

Solution

  • try .one function for one interface

    require('node-macaddress').one(function (err, addr) { console.log(addr); }
    

    On node ≥ 0.11 you are not required to use the asynchronous version try

    var addr = require('node-macaddress').one();