Skip to content

Axorax/get-os-ip.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

get-os-ip.js

Get local IPv4 or IPv6 address

⚙️ Installation

npm i get-os-ip

CDN Links:

📖 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);

Support me on PatreonCheck out my socials