mirror of
https://github.com/pi-hole/pi-hole
synced 2024-12-22 14:58:08 +00:00
Handle more than one default gateway in debug script
Signed-off-by: Christian König <ckoenig@posteo.de>
This commit is contained in:
parent
4f4dfe3ac0
commit
bb57a9e616
@ -680,17 +680,18 @@ ping_gateway() {
|
|||||||
# Check if we are using IPv4 or IPv6
|
# Check if we are using IPv4 or IPv6
|
||||||
# Find the default gateway using IPv4 or IPv6
|
# Find the default gateway using IPv4 or IPv6
|
||||||
local gateway
|
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 the gateway array is not empty (meaning a gateway was found),
|
||||||
if [[ -n "${gateway}" ]]; then
|
if [[ ${#gateway[@]} -ne 0 ]]; then
|
||||||
log_write "${INFO} Default IPv${protocol} gateway: ${gateway}"
|
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
|
# 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,
|
# 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
|
# on the pihole interface, and tail the last three lines of the output
|
||||||
# If pinging the gateway is not successful,
|
# 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
|
# let the user know
|
||||||
log_write "${CROSS} ${COL_RED}Gateway did not respond.${COL_NC} ($FAQ_GATEWAY)\\n"
|
log_write "${CROSS} ${COL_RED}Gateway did not respond.${COL_NC} ($FAQ_GATEWAY)\\n"
|
||||||
# and return an error code
|
# and return an error code
|
||||||
|
Loading…
Reference in New Issue
Block a user