diff --git a/lib/ip.js b/lib/ip.js index c1799a8..be661eb 100644 --- a/lib/ip.js +++ b/lib/ip.js @@ -376,7 +376,22 @@ ip.address = function(name, family) { return res[0].address; } - var all = Object.keys(interfaces).map(function (nic) { + function priority(name) { + if (name.slice(0, 2) === 'en' || name.slice(0, 3) === 'eth') { + return 0; + } + if (name.slice(0, 4) === 'wlan') { + return 1; + } + + return 2; + } + + var sortedInterfaces = Object.keys(interfaces).sort(function(a, b) { + return priority(a) - priority(b); + }); + + var all = sortedInterfaces.map(function(nic) { // // Note: name will only be `public` or `private` // when this is called.