Skip to content

Instantly share code, notes, and snippets.

@stiekel
Last active August 29, 2015 14:22
Show Gist options
  • Save stiekel/554b107a514a0ba24abf to your computer and use it in GitHub Desktop.
Save stiekel/554b107a514a0ba24abf to your computer and use it in GitHub Desktop.
Get local server all public IPs
var os = require('os');
//get all public ips
var getMyPublicIp = function(){
var nics = os.networkInterfaces();
var ips = [];
for(var i in nics) {
nics[i].forEach(function(cfg){
if(!cfg.internal) {
ips.push(cfg.address);
}
});
}
return ips;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment