address
Get current machine IP, MAC and DNS servers.
DNS servers receive from /etc/resolv.conf
.
Install
$ npm install address
Usage
Get IP is sync and get MAC is async for now.
var address = require('address');
address.ip();
address.ipv6();
address.mac(function (err, addr) {
console.log(addr);
});
address.ip('lo');
address.mac('vboxnet', function (err, addr) {
console.log(addr);
});
Get all addresses: IPv4, IPv6 and MAC
address(function (err, addrs) {
console.log(addrs.ip, addrs.ipv6, addrs.mac);
});
address('vboxnet', function (err, addrs) {
console.log(addrs.ip, addrs.ipv6, addrs.mac);
});
Get an interface info with family
address.interface('IPv4', 'eth1');
Get DNS servers
address.dns(function (err, addrs) {
console.log(addrs);
});
benchmark
run $ npm run benchmark
18,929 op/s » #ip
17,622 op/s » #ipv6
16,347 op/s » #mac
11,906 op/s » #dns
License
MIT
Contributors
This project follows the git-contributor spec, auto updated at Fri Apr 29 2022 20:59:23 GMT+0800
.