get-os-ip
v1.0.0
Published
Get local IPv4 or IPv6 address
Downloads
17
Maintainers
Readme
⚙️ Installation
npm i get-os-ip
CDN Links:
- https://cdn.jsdelivr.net/npm/[email protected]/get-os-ip.js
- https://www.unpkg.com/[email protected]/get-os-ip.js
📖 Usage
● Import
// ES6
import getOsIp from "get-os-ip";
// commonjs
const getOsIp = require("get-os-ip");
● Local IPv6
const ipv6 = getOsIp(); // ⌝
// | "2001:0db8:85a3:0000:0000:8a2e:0370:7334"
const alsoIpv6 = getOsIp("v6"); // ⌟
console.log('Local IPv6: ' + ipv6);
● Local IPv4
const ipv4 = getOsIp("v4"); // 172.16.254.1
console.log('Local IPv4: ' + ipv4);