Get your private IP address.
Install private-ip-address
with your favorite package manager:
$ npm i private-ip-address -D
# or
$ yarn add private-ip-address -D
# or
$ pnpm i private-ip-address -D
# or
$ bun add private-ip-address -D
To use private-ip-address
, import the internalIPv4
or internalIPv6
function:
// esm
import { internalIPv4, internalIPv6 } from 'private-ip-address';
// cjs
const { internalIPv4, internalIPv6 } = require('private-ip-address');
console.log(`Internal IPv4 address: ${internalIPv4()}`);
// Internal IPv4 address: 192.168.100.202
console.log(`Internal IPv6 address: ${internalIPv6()}`);
// Internal IPv6 address: fe80::ac97:42ff:fe19:cea