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:
authorChristian König <ckoenig@posteo.de>2022-09-22 23:33:11 +0300
committerChristian König <ckoenig@posteo.de>2022-09-22 23:33:11 +0300
commitbb57a9e6168b52b91e3ac04e59734aa270d81e10 (patch)
tree7d0aa5437d00cc4be37c66da1abf28d1cd1e210c
parent4f4dfe3ac0c487c2db594e1bd923ef3d31299a66 (diff)
Handle more than one default gateway in debug scriptone_gateway
Signed-off-by: Christian König <ckoenig@posteo.de>
-rwxr-xr-xadvanced/Scripts/piholeDebug.sh13
1 files changed, 7 insertions, 6 deletions
diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh
index ab16d7ff..074b2d1f 100755
--- a/advanced/Scripts/piholeDebug.sh
+++ b/advanced/Scripts/piholeDebug.sh
@@ -680,17 +680,18 @@ ping_gateway() {
# Check if we are using IPv4 or IPv6
# Find the default gateway using IPv4 or IPv6
local gateway
- gateway="$(ip -"${protocol}" route | grep default | grep "${PIHOLE_INTERFACE}" | cut -d ' ' -f 3)"
+ mapfile -t 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}"
+ # If the gateway array is not empty (meaning a gateway was found),
+ if [[ ${#gateway[@]} -ne 0 ]]; then
+ log_write "${INFO} Default IPv${protocol} gateway(s):"
+ for i in "${gateway[@]}"; do log_write " $i"; done
# Let the user know we will ping the gateway for a response
- log_write " * Pinging ${gateway}..."
+ log_write " * Pinging first gateway ${gateway[0]}..."
# 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,
- if ! ${cmd} -c 1 -W 2 -n "${gateway}" -I "${PIHOLE_INTERFACE}" >/dev/null; then
+ if ! ${cmd} -c 1 -W 2 -n "${gateway[0]}" -I "${PIHOLE_INTERFACE}" >/dev/null; then
# let the user know
log_write "${CROSS} ${COL_RED}Gateway did not respond.${COL_NC} ($FAQ_GATEWAY)\\n"
# and return an error code