Last change
on this file since 84d0fbb was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.3 KB
|
Rev | Line | |
---|
[6a3a178] | 1 | # internal-ip [![Build Status](https://travis-ci.org/sindresorhus/internal-ip.svg?branch=master)](https://travis-ci.org/sindresorhus/internal-ip)
|
---|
| 2 |
|
---|
| 3 | > Get your internal IP address
|
---|
| 4 |
|
---|
| 5 |
|
---|
| 6 | ## Install
|
---|
| 7 |
|
---|
| 8 | ```
|
---|
| 9 | $ npm install internal-ip
|
---|
| 10 | ```
|
---|
| 11 |
|
---|
| 12 |
|
---|
| 13 | ## Usage
|
---|
| 14 |
|
---|
| 15 | ```js
|
---|
| 16 | const internalIp = require('internal-ip');
|
---|
| 17 |
|
---|
| 18 | (async () => {
|
---|
| 19 | console.log(await internalIp.v6());
|
---|
| 20 | //=> 'fe80::1'
|
---|
| 21 |
|
---|
| 22 | console.log(await internalIp.v4());
|
---|
| 23 | //=> '10.0.0.79'
|
---|
| 24 | })();
|
---|
| 25 |
|
---|
| 26 | console.log(internalIp.v6.sync())
|
---|
| 27 | //=> 'fe80::1'
|
---|
| 28 |
|
---|
| 29 | console.log(internalIp.v4.sync())
|
---|
| 30 | //=> '10.0.0.79'
|
---|
| 31 | ```
|
---|
| 32 |
|
---|
| 33 | The module returns the address of the internet-facing interface, as determined from the default gateway. When the address cannot be determined for any reason, `null` will be returned.
|
---|
| 34 |
|
---|
| 35 | The module relies on operating systems tools. On Linux and Android, the `ip` command must be available, which depending on distribution might not be installed by default. It is usually provided by the `iproute2` package.
|
---|
| 36 |
|
---|
| 37 |
|
---|
| 38 | ## Related
|
---|
| 39 |
|
---|
| 40 | - [internal-ip-cli](https://github.com/sindresorhus/internal-ip-cli) - CLI for this module
|
---|
| 41 | - [public-ip](https://github.com/sindresorhus/public-ip) - Get your public IP address
|
---|
| 42 | - [default-gateway](https://github.com/silverwind/default-gateway) - Get your default gateway address
|
---|
| 43 |
|
---|
| 44 |
|
---|
| 45 | ## License
|
---|
| 46 |
|
---|
| 47 | MIT © [Sindre Sorhus](https://sindresorhus.com)
|
---|
Note:
See
TracBrowser
for help on using the repository browser.