Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

3 лет назад
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. internalIp.v6().then(ip => {
  11. console.log(ip);
  12. //=> 'fe80::1'
  13. });
  14. internalIp.v4().then(ip => {
  15. console.log(ip);
  16. //=> '10.0.0.79'
  17. });
  18. console.log(internalIp.v6.sync())
  19. //=> 'fe80::1'
  20. console.log(internalIp.v4.sync())
  21. //=> '10.0.0.79'
  22. ```
  23. The module returns the address of the internet-facing interface, as determined from the default gateway. When the adress cannot be determined for any reason, `null` will be returned.
  24. 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.
  25. ## Related
  26. - [internal-ip-cli](https://github.com/sindresorhus/internal-ip-cli) - CLI for this module
  27. - [public-ip](https://github.com/sindresorhus/public-ip) - Get your public IP address
  28. - [default-gateway](https://github.com/silverwind/default-gateway) - Get your default gateway address
  29. ## License
  30. MIT © [Sindre Sorhus](https://sindresorhus.com)