Last active
August 29, 2015 14:22
-
-
Save stiekel/554b107a514a0ba24abf to your computer and use it in GitHub Desktop.
Get local server all public IPs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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