Introduction:
This bash script checks the network connectivity by pinging common websites or IP addresses. It helps diagnose issues with your internet connection quickly.
Instructions:
To use this script, follow these commands:
Example Output:
This bash script checks the network connectivity by pinging common websites or IP addresses. It helps diagnose issues with your internet connection quickly.
Bash:
#!/bin/bash
# List of hosts to check
hosts=("google.com" "amazon.com" "cloudflare.com")
for host in "${hosts[@]}"
do
echo "Pinging $host..."
ping -c 1 $host &> /dev/null
if [ $? -eq 0 ]; then
echo "$host is up."
else
echo "$host is down."
fi
done
Instructions:
To use this script, follow these commands:
Code:
chmod +x network_check.sh
./network_check.sh
Example Output:
Code:
Pinging google.com...
google.com is up.
Pinging amazon.com...
amazon.com is up.
Pinging cloudflare.com...
cloudflare.com is up.