dn42-info/pinger.sh
2024-05-12 16:45:33 +02:00

40 lines
No EOL
735 B
Bash
Executable file

#!/bin/bash
# List of targets to ping (replace with your desired addresses/hostnames)
targets=("google.com" "cloudflare.com" "example.com")
ipv4=false
ipv6=false
# --- Main Script ---
echo "Checking network connectivity:"
if ping -c 1 -W 1 "8.8.8.8" &>/dev/null; then
echo "IPv4: yes"
ipv4=true
else
echo "IPv4: no"
fi
if ping -c 1 -W 1 "2001:4860:4860::8844" &>/dev/null; then
echo "IPv6: yes"
ipv6=true
else
echo "IPv6: no"
fi
echo "Pings to targets:"
# Ping each target over IPv4 and IPv6
for target in "${targets[@]}"; do
echo "--- $target ---"
# IPv4 ping
ping -i 0.2 -c 4 $target
# IPv6 ping
ping6 -c 4 $target
echo "" # Add a blank line for separation
done