From 1adc25308f82c4f41348b04f61c950685387e59f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=AE=B6=E4=BC=9F?= Date: Fri, 30 Jun 2023 15:22:32 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E4=B8=BB=E6=9C=BA=E7=BD=91?= =?UTF-8?q?=E7=BB=9C=E8=BF=9E=E6=8E=A5=E4=BF=A1=E6=81=AF=E6=97=B6=E6=8C=89?= =?UTF-8?q?=E7=B4=A2=E5=BC=95=E4=BB=8E=E5=B0=8F=E5=88=B0=E5=A4=A7=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=EF=BC=8C=E4=BC=98=E5=85=88=E4=BD=BF=E7=94=A8=E7=B4=A2?= =?UTF-8?q?=E5=BC=95=E5=80=BC=E5=B0=8F=E7=9A=84=E7=BD=91=E7=BB=9C=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/tech/powerjob/common/utils/NetUtils.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/powerjob-common/src/main/java/tech/powerjob/common/utils/NetUtils.java b/powerjob-common/src/main/java/tech/powerjob/common/utils/NetUtils.java index 1b84ab4b..9a0d88a3 100644 --- a/powerjob-common/src/main/java/tech/powerjob/common/utils/NetUtils.java +++ b/powerjob-common/src/main/java/tech/powerjob/common/utils/NetUtils.java @@ -155,6 +155,9 @@ public class NetUtils { log.warn("[Net] findNetworkInterface failed", e); } + // sort by interface index, the smaller is preferred. + validNetworkInterfaces.sort(Comparator.comparingInt(NetworkInterface::getIndex)); + // Try to find the preferred one for (NetworkInterface networkInterface : validNetworkInterfaces) { if (isPreferredNetworkInterface(networkInterface)) {