From bbc373d1577709eb0cb674498a7075da6bfe9067 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Thu, 11 Feb 2021 21:13:57 +0100 Subject: [PATCH] Check gateway using ping from interface --- .../root/usr/libexec/rpcd/openmptcprouter | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/luci-app-openmptcprouter/root/usr/libexec/rpcd/openmptcprouter b/luci-app-openmptcprouter/root/usr/libexec/rpcd/openmptcprouter index b80a81a7d..bc36f9649 100755 --- a/luci-app-openmptcprouter/root/usr/libexec/rpcd/openmptcprouter +++ b/luci-app-openmptcprouter/root/usr/libexec/rpcd/openmptcprouter @@ -1232,7 +1232,12 @@ function interfaces_status() if gateway ~= "" or gateway6 ~= "" then if uci:get("openmptcprouter", "settings", "disablegwping") ~= "1" and connectivity ~= "ERROR" then if gateway ~= "" then - local gw_ping_test = ut.trim(sys.exec("ping -w 1 -c 1 " .. gateway .. " | grep '100% packet loss'")) + local gw_ping_test = "" + if ifname ~= "" and ifname ~= nil then + gw_ping_test = ut.trim(sys.exec("ping -w 1 -c 1 -I " .. ifname .. " " .. gateway .. " | grep '100% packet loss'")) + else + gw_ping_test = ut.trim(sys.exec("ping -w 1 -c 1 " .. gateway .. " | grep '100% packet loss'")) + end if gw_ping_test ~= "" then gw_ping = "DOWN" if connectivity == "OK" then @@ -1241,7 +1246,12 @@ function interfaces_status() end end if gateway6 ~= "" then - local gw_ping6_test = ut.trim(sys.exec("ping -w 1 -c 1 " .. gateway6 .. " | grep '100% packet loss'")) + local gw_ping6_test = "" + if ifname ~= "" and ifname ~= nil then + gw_ping6_test = ut.trim(sys.exec("ping -w 1 -c 1 -I " .. ifname .. " " .. gateway6 .. " | grep '100% packet loss'")) + else + gw_ping6_test = ut.trim(sys.exec("ping -w 1 -c 1 " .. gateway6 .. " | grep '100% packet loss'")) + end if gw_ping6_test ~= "" then gw_ping6 = "DOWN" if connectivity == "OK" then