UNPKG

1.82 kBMarkdownView Raw
1# internal-ip
2
3> Get your internal IP address
4
5## Install
6
7```sh
8npm install internal-ip
9```
10
11## Usage
12
13```js
14import {internalIpV6, internalIpV4} from 'internal-ip';
15
16console.log(await internalIpV6());
17//=> 'fe80::1'
18
19console.log(await internalIpV4());
20//=> '10.0.0.79'
21```
22
23## API
24
25The package returns the address of the internet-facing interface, as determined from the default gateway. When the address cannot be determined for any reason, `undefined` will be returned.
26
27The package 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. `internalIpV6Sync()` and `internalIpV4Sync()` are not supported in browsers and just return `undefined`.
28
29### internalIpV6()
30
31Returns the internal IPv6 address asynchronously.
32
33### internalIpV4()
34
35Returns the internal IPv4 address asynchronously.
36
37### internalIpV6Sync()
38
39Returns the internal IPv6 address synchronously.
40
41### internalIpV4Sync()
42
43Returns the internal IPv4 address synchronously.
44
45## Related
46
47- [internal-ip-cli](https://github.com/sindresorhus/internal-ip-cli) - CLI for this package
48- [public-ip](https://github.com/sindresorhus/public-ip) - Get your public IP address
49- [default-gateway](https://github.com/silverwind/default-gateway) - Get your default gateway address
50
51---
52
53<div align="center">
54 <b>
55 <a href="https://tidelift.com/subscription/pkg/npm-internal-ip?utm_source=npm-internal-ip&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
56 </b>
57 <br>
58 <sub>
59 Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
60 </sub>
61</div>