Skip to content

Instantly share code, notes, and snippets.

@nhancv
Last active October 30, 2021 12:32
Show Gist options
  • Select an option

  • Save nhancv/28a97fae9daab89b31eb5c87778ee66d to your computer and use it in GitHub Desktop.

Select an option

Save nhancv/28a97fae9daab89b31eb5c87778ee66d to your computer and use it in GitHub Desktop.
Get current lan ip address with nodejs
var address, ifaces = require('os').networkInterfaces()
for (var dev in ifaces) {
ifaces[dev].filter((details) => details.family === 'IPv4' && details.internal === false ? address = details.address : undefined)
if(address) break
}
console.log(address)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment