# network

> Cross platform network utilities for Node.js (gateway_ip, MAC address, etc)

Latest version **0.7.0** (published 2024-01-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install network
pnpm add network
yarn add network
bun add network
```

Provides the command `network`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.7.0 |
| Published | 2024-01-24 |
| First published | 2014-03-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 18.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 113 |
| Author | Tomas Pollak |
| Maintainers | tomas |

## Links

- npm: https://www.npmjs.com/package/network
- Repository: https://github.com/tomas/network
- Homepage: https://github.com/tomas/network#readme
- Issues: https://github.com/tomas/network/issues
- npm.io page: https://npm.io/package/network

## Dependencies (4)

- [wmic](https://npm.io/package/wmic.md) ^1.0.1
- [async](https://npm.io/package/async.md) ^1.5.2
- [needle](https://npm.io/package/needle.md) ^3.0.0
- [commander](https://npm.io/package/commander.md) 2.9.0

## Recent versions

- 0.7.0 (latest) — 2024-01-24
- 0.6.1 — 2021-12-31
- 0.6.0 — 2021-09-15
- 0.5.0 — 2020-02-21
- 0.4.1 — 2018-02-13
- 0.4.0 — 2017-09-11
- 0.3.2 — 2017-01-17
- 0.3.0 — 2016-09-23
- 0.2.1 — 2016-06-12
- 0.2.0 — 2016-06-02
- 0.1.3 — 2014-10-09
- 0.1.2 — 2014-10-04
- 0.1.1 — 2014-09-30
- 0.1.0 — 2014-09-29
- 0.0.12 — 2014-09-10
- … 11 more at https://npm.io/package/network/versions

## README

Network Utilies for Node.js
===========================

# Install

    $ npm install network

# Usage

## Get public IP

Returns your public IP address, as reported by DynDNS.org or other services.

``` js
var network = require('network');

network.get_public_ip(function(err, ip) {
  console.log(err || ip); // should return your public IP address
})
```

##### CLI

    $ network public_ip

## Get private IP

Returns the IP address assigned to your first active network inteface.

``` js
network.get_private_ip(function(err, ip) {
  console.log(err || ip); // err may be 'No active network interface found'.
})
```

##### CLI

    $ network private_ip

## Get gateway IP

Returns the IP of the gateway that your active network interface is linked to.

``` js
network.get_gateway_ip(function(err, ip) {
  console.log(err || ip); // err may be 'No active network interface found.'
})
```

##### CLI

    $ network gateway_ip

## Get active interface

Returns the IP, MAC address and interface type for the active network
interface. On OS X and Linux you also get the IP of its assigned gateway.

``` js
network.get_active_interface(function(err, obj) {

  /* obj should be:

  { name: 'eth0',
    ip_address: '10.0.1.3',
    mac_address: '56:e5:f9:e4:38:1d',
    type: 'Wired',
    netmask: '255.255.255.0',
    gateway_ip: '10.0.1.1' }

  */
})
```

##### CLI

    $ network active_interface

## Get interfaces list

Returns list of network interfaces, including MAC addresses and the such, just
as in the example above.

``` js
network.get_interfaces_list(function(err, list) {

  /* list should be:

  [{
    name: 'eth0',
    ip_address: '10.0.1.3',
    mac_address: '56:e5:f9:e4:38:1d',
    type: 'Wired',
    netmask: '255.255.255.0',
    gateway_ip: '10.0.1.1' 
   },
   { ... }, { ... }]

  */
})
```

##### CLI

    $ network interfaces_list

# Copyright

Written by Tomás Pollak. Copyright (c) Fork, Ltd.

# License

MIT.

---
_Source: https://npm.io/package/network · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
