address
Get current machine IP, MAC and DNS servers.
DNS servers receive from /etc/resolv.conf.
Install
$ npm install addressUsage
Get IP is sync and get MAC is async for now.
var address = require('address');
// default interface 'eth' on linux, 'en' on osx.
address.ip(); // '192.168.0.2'
address.ipv6(); // 'fe80::7aca:39ff:feb0:e67d'
address.mac(function (err, addr) {
console.log(addr); // '78:ca:39:b0:e6:7d'
});
// local loopback
address.ip('lo'); // '127.0.0.1'
// vboxnet MAC
address.mac('vboxnet', function (err, addr) {
console.log(addr); // '0a:00:27:00:00:00'
});Get all addresses: IPv4, IPv6 and MAC
Get an interface info with family
Get DNS servers
benchmark
run $ npm run benchmark
License
Last updated
Was this helpful?