# non-private-ip

> see if you have a non private (i.e. public ip address)

Latest version **2.2.0** (published 2022-01-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install non-private-ip
pnpm add non-private-ip
yarn add non-private-ip
bun add non-private-ip
```

Provides the command `non-private-ip`.

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.2.0 |
| Published | 2022-01-26 |
| First published | 2014-12-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 9.9 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Dominic Tarr |
| Maintainers | dominictarr, staltz, arj03 |

## Links

- npm: https://www.npmjs.com/package/non-private-ip
- Repository: https://github.com/dominictarr/non-private-ip
- Issues: https://github.com/dominictarr/non-private-ip/issues
- npm.io page: https://npm.io/package/non-private-ip

## Dependencies (1)

- [ip](https://npm.io/package/ip.md) ^1.1.5

## Recent versions

- 2.2.0 (latest) — 2022-01-26
- 2.1.0 — 2022-01-25
- 2.0.0 — 2022-01-25
- 1.4.4 — 2018-05-29
- 1.4.3 — 2018-02-07
- 1.4.2 — 2017-03-19
- 1.4.1 — 2016-10-06
- 1.4.0 — 2016-10-06
- 1.3.0 — 2015-07-30
- 1.2.1 — 2015-02-11
- 1.2.0 — 2015-02-09
- 1.1.0 — 2014-12-26
- 1.0.1 — 2014-12-26

## README

# non-private-ip

Picks the first reasonable looking IP address from network interfaces.
This should _just work_ when running on a VPS, but also provides `private` APIs
so that when running in LAN you get the first reasonable looking LAN IP address.

More info: http://en.wikipedia.org/wiki/Private_network

Your laptop probably does not have a non-local IP address, but your VPS server
probably does. This just returns the first address, which will probably be IPv4.

This module is based on the ["ip" module](https://www.npmjs.com/package/ip).

## API

The main export is a function `nonPrivateIP(interfaces, filter, details)` where:

- `interfaces` is either `null` or a mock of `os.networkInterfaces()`, typically
  **this should be `null`**
- `filter` is a **function** of the shape `(address, details) => boolean` where
  `address` is the IP address as a string, and `details` is the whole object
  with additional fields, e.g. `address`, `netmask`, `family`, `mac`, `cidr`,
  etc
- `details` is a boolean that controls whether you want the return of the
  function to be just the IP address as a string (`false`, this is the
  **default**) or the whole object with additional fields (`true`)

```js
// On a VPS:
const nonPrivateIP = require('non-private-ip')
nonPrivateIP() // 80.78.25.153
```

```js
// In a LAN:
const nonPrivateIP = require('non-private-ip')
nonPrivateIP.private() // 192.168.0.101
```

## License

MIT

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