f367a36cfb4b4f9e9c43b537c1a03fbced9a1c04d5ae8a5f8b651af5bd5f512dbb7a5e19761a2917ed4885d0286a8ca75064483f5de1d294b49f145aaf484f 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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)