mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 10:43:55 +00:00
Handle more than one default gateway in debug script (#4934)
This commit is contained in:
commit
f8a12917e2
1 changed files with 11 additions and 6 deletions
|
@ -678,15 +678,20 @@ ping_gateway() {
|
||||||
local protocol="${1}"
|
local protocol="${1}"
|
||||||
ping_ipv4_or_ipv6 "${protocol}"
|
ping_ipv4_or_ipv6 "${protocol}"
|
||||||
# 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 gateways using IPv4 or IPv6
|
||||||
local gateway
|
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),
|
log_write "${INFO} Default IPv${protocol} gateway(s):"
|
||||||
if [[ -n "${gateway}" ]]; then
|
|
||||||
log_write "${INFO} Default IPv${protocol} gateway: ${gateway}"
|
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
|
# 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,
|
# 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,
|
||||||
|
|
Loading…
Reference in a new issue