Skip to content

Instantly share code, notes, and snippets.

@theaccordance
Created March 3, 2016 17:29
Show Gist options
  • Select an option

  • Save theaccordance/27c1058850e715ef52e4 to your computer and use it in GitHub Desktop.

Select an option

Save theaccordance/27c1058850e715ef52e4 to your computer and use it in GitHub Desktop.
var os = require('os');
function getLocalIp() {
var interfaces = os.networkInterfaces(),
address = '';
for (var k in interfaces) {
for (var k2 in interfaces[k]) {
var intf = interfaces[k][k2];
if (intf.family == 'IPv4' && !intf.internal) {
address = intf.address;
}
}
}
return address;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment