how to get local IP address in node
function getIPAdress(){ var interfaces = require(‘os’).networkInterfaces(); for(var devName in interfaces){ var iface = interfaces[devName]; for(var i=0;i<iface.length;i++){ var alias = iface[i]; if(alias.family === ‘IPv4’ && alias.address !== ‘127.0.0.1’ && !alias.internal){ return alias.address; } } } }
4 回复
http://blog.csdn.net/fifaquake/article/details/7532145
这篇也不错,有兴趣可以看看
http://blog.csdn.net/marujunyy/article/details/8487267
这篇里面提供了获取本地外网ip的方法,有点yd