npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

address

v2.0.3

Published

Get current machine IP, MAC and DNS servers.

Downloads

40,641,142

Readme

address

NPM version Node.js CI Test coverage npm download

Get current machine IPv4, IPv6, 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.

  • esm & typescript
import { ip, ipv6, mac } from 'address';

// default interface 'eth' on linux, 'en' on osx.
ip();   // '192.168.0.2'
ipv6(); // 'fe80::7aca:39ff:feb0:e67d'
mac(function (err, addr) {
  console.log(addr); // '78:ca:39:b0:e6:7d'
});

// local loopback
ip('lo'); // '127.0.0.1'

// vboxnet MAC
mac('vboxnet', function (err, addr) {
  console.log(addr); // '0a:00:27:00:00:00'
});
  • commonjs
const { ip, ipv6, mac } = require('address');

// default interface 'eth' on linux, 'en' on osx.
ip();   // '192.168.0.2'
ipv6(); // 'fe80::7aca:39ff:feb0:e67d'
mac(function (err, addr) {
  console.log(addr); // '78:ca:39:b0:e6:7d'
});

// local loopback
ip('lo'); // '127.0.0.1'

// vboxnet MAC
mac('vboxnet', function (err, addr) {
  console.log(addr); // '0a:00:27:00:00:00'
});

Get all addresses: IPv4, IPv6 and MAC

  • esm & typescript
import { address } from 'address';

address((err, addrs) => {
  console.log(addrs.ip, addrs.ipv6, addrs.mac);
  // '192.168.0.2', 'fe80::7aca:39ff:feb0:e67d', '78:ca:39:b0:e6:7d'
});

address('vboxnet', (err, addrs) => {
  console.log(addrs.ip, addrs.ipv6, addrs.mac);
  // '192.168.56.1', null, '0a:00:27:00:00:00'
});
  • commonjs
const { address } = require('address');

address((err, addrs) => {
  console.log(addrs.ip, addrs.ipv6, addrs.mac);
  // '192.168.0.2', 'fe80::7aca:39ff:feb0:e67d', '78:ca:39:b0:e6:7d'
});

address('vboxnet', (err, addrs) => {
  console.log(addrs.ip, addrs.ipv6, addrs.mac);
  // '192.168.56.1', null, '0a:00:27:00:00:00'
});

Get an interface info with family

  • esm & typescript
import { getInterfaceAddress } from 'address';

getInterfaceAddress('IPv4', 'eth1');
// { address: '192.168.1.1', family: 'IPv4', mac: '78:ca:39:b0:e6:7d' }
  • commonjs
const { getInterfaceAddress } = require('address');

getInterfaceAddress('IPv4', 'eth1');
// { address: '192.168.1.1', family: 'IPv4', mac: '78:ca:39:b0:e6:7d' }

Get DNS servers

  • esm & typescript
import { dns } from 'address';

dns((err, servers) => {
  console.log(servers);
  // ['10.13.2.1', '10.13.2.6']
});
  • commonjs
const { dns } = require('address');

dns((err, servers) => {
  console.log(servers);
  // ['10.13.2.1', '10.13.2.6']
});

Promise style apis

import { address, mac, dns } from 'address/promises';

const addr = await address();
const macAddress = await mac();
const servers = await dns();

License

MIT

Contributors

|fengmk2|alsotang|jkelleyrtp|slyon|mariodu|mathieutu| | :---: | :---: | :---: | :---: | :---: | :---: | zhangyuheng|semantic-release-bot|coolme200|whxaxes

This project follows the git-contributor spec, auto updated at Fri Sep 22 2023 20:49:32 GMT+0800.