Get self IP addresses
- Supports TypeScript
- Supports both CommonJS and ESModules
$ npm install --save self-ip # for npm users
$ yarn add self-ip # for yarn users
There are breaking changes in v1.0.0
. See the release note for more details.
import { ip, ipv4, ipv6 } from 'self-ip'
ip()
// ==> { v4: ['192.0.0.2'], v6: ['ffff::abcd:1234:1234:5678'] }
ipv4()
// ==> ['192.0.0.2']
ipv6()
// ==> ['ffff::abcd:1234:1234:5678']
const { ip, ipv4, ipv6 } = require('self-ip')
ip()
// ==> { v4: ['192.0.0.2'], v6: ['ffff::abcd:1234:1234:5678'] }
ipv4()
// ==> ['192.0.0.2']
ipv6()
// ==> ['ffff::abcd:1234:1234:5678']
Get both IPv4 and IPv6 self-addresses
checker(addrs, name)
(function): check if it is a loopback network interface or not- default: is-lo module
- Result (Object):
{ v4: ['v4addr'], v6: ['v6addr'] }
Get IPv4 self-addresses
checker(addrs, name)
(function): check if it is a loopback network interface or not- default: is-lo module
- Result (Array):
['v4addr']
Get IPv6 self-addresses
checker(addrs, name)
(function): check if it is a loopback network interface or not- default: is-lo module
- Result (Array):
['v6addr']
MIT © Pine Mizune