You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.3 KiB

4 years ago
  1. # internal-ip [![Build Status](https://travis-ci.org/sindresorhus/internal-ip.svg?branch=master)](https://travis-ci.org/sindresorhus/internal-ip)
  2. > Get your internal IP address
  3. ## Install
  4. ```
  5. $ npm install internal-ip
  6. ```
  7. ## Usage
  8. ```js
  9. const internalIp = require('internal-ip');
  10. (async () => {
  11. console.log(await internalIp.v6());
  12. //=> 'fe80::1'
  13. console.log(await internalIp.v4());
  14. //=> '10.0.0.79'
  15. })();
  16. console.log(internalIp.v6.sync())
  17. //=> 'fe80::1'
  18. console.log(internalIp.v4.sync())
  19. //=> '10.0.0.79'
  20. ```
  21. 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.
  22. 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.
  23. ## Related
  24. - [internal-ip-cli](https://github.com/sindresorhus/internal-ip-cli) - CLI for this module
  25. - [public-ip](https://github.com/sindresorhus/public-ip) - Get your public IP address
  26. - [default-gateway](https://github.com/silverwind/default-gateway) - Get your default gateway address
  27. ## License
  28. MIT © [Sindre Sorhus](https://sindresorhus.com)