diff --git a/lib/address.js b/lib/address.js index 8172c19..d4e5ebc 100644 --- a/lib/address.js +++ b/lib/address.js @@ -86,12 +86,13 @@ address.interface = function (family, name) { } if (noName) { - // filter 127.0.0.1, get the first ip + // filter all loopback or local addresses for (var k in interfaces) { var items = interfaces[k]; for (var i = 0; i < items.length; i++) { var item = items[i]; - if (matchName(item.family, family) && item.address !== '127.0.0.1') { + // all 127 addresses are local and should be ignored + if (matchName(item.family, family) && !item.address.startsWith('127.')) { return item; } }