Skip to content

Latest commit

 

History

History
28 lines (20 loc) · 524 Bytes

how-to-get-ip-address.md

File metadata and controls

28 lines (20 loc) · 524 Bytes

How to get IP address

const os = require('os');
const net = os.networkInterfaces();

let ip = net.eth0[0].address;
  • require('os') - module to work with OS
  • .networkInterfaces() - returns data on all network interfaces
  • net.eth0[0].address - returns first IP address of eth0 interface

group: hostname

Example:

const os = require('os');
const net = os.networkInterfaces();

console.log(net.eth0[0].address);
135.181.98.214

link_youtube: https://youtu.be/4DYtx9WoKDk