Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/pi-hole/pi-hole.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Schaper <dan.schaper@pi-hole.net>2022-09-25 21:09:26 +0300
committerGitHub <noreply@github.com>2022-09-25 21:09:26 +0300
commitf8a12917e2549f2070380053c7fc553f60e77101 (patch)
treeb8cf0a49d7a74891ccdb99b7322603458250c6bf
parent37b45d411dfab9a68d77a195edb26b3fa3d24399 (diff)
parent22ebf2148762178351541fd22f3af99755fba291 (diff)
Handle more than one default gateway in debug script (#4934)
-rwxr-xr-xadvanced/Scripts/piholeDebug.sh17
1 files changed, 11 insertions, 6 deletions
diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh
index ab16d7ff..91e16850 100755
--- a/advanced/Scripts/piholeDebug.sh
+++ b/advanced/Scripts/piholeDebug.sh
@@ -678,15 +678,20 @@ ping_gateway() {
local protocol="${1}"
ping_ipv4_or_ipv6 "${protocol}"
# Check if we are using IPv4 or IPv6
- # Find the default gateway using IPv4 or IPv6
+ # Find the default gateways using IPv4 or IPv6
local gateway
- gateway="$(ip -"${protocol}" route | grep default | grep "${PIHOLE_INTERFACE}" | cut -d ' ' -f 3)"
- # If the gateway variable has a value (meaning a gateway was found),
- if [[ -n "${gateway}" ]]; then
- log_write "${INFO} Default IPv${protocol} gateway: ${gateway}"
+ log_write "${INFO} Default IPv${protocol} gateway(s):"
+
+ while IFS= read -r gateway; do
+ log_write " ${gateway}"
+ done < <(ip -"${protocol}" route | grep default | grep "${PIHOLE_INTERFACE}" | cut -d ' ' -f 3)
+
+ gateway=$(ip -"${protocol}" route | grep default | grep "${PIHOLE_INTERFACE}" | cut -d ' ' -f 3 | head -n 1)
+ # If there was at least one gateway
+ if [ -n "${gateway}" ]; then
# Let the user know we will ping the gateway for a response
- log_write " * Pinging ${gateway}..."
+ log_write " * Pinging first gateway ${gateway}..."
# Try to quietly ping the gateway 3 times, with a timeout of 3 seconds, using numeric output only,
# on the pihole interface, and tail the last three lines of the output
# If pinging the gateway is not successful,