Skip to content

Instantly share code, notes, and snippets.

@drugoi
Last active August 29, 2015 14:02
Show Gist options
  • Save drugoi/b1f9424b0f9cd86d0ff2 to your computer and use it in GitHub Desktop.
Save drugoi/b1f9424b0f9cd86d0ff2 to your computer and use it in GitHub Desktop.
Get current ip in node.js
var os = require('os');
var ifaces = os.networkInterfaces();
for (var dev in ifaces) {
var alias = 0;
ifaces[dev].forEach(function(details) {
if (details.family == 'IPv4') {
if (details.address == '127.0.0.1') {
return;
}
++alias;
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment