I want to write a shell script to test reachability of networks. I have 4 routers and 20 clients. I need to check whether each of these 20 clients are reachable from each single router. What I have is :
for ((i=0; i< ${#Hostname[@]}; i++))
do
ping $i > /dev/null
if [$? -eq 0]
then
echo $i "Reachable"
else
echo $i "Not Reachable from this router"
fi
done
Now my problem is that I have no idea how to declare which router to start the testing from. I was wondering whether I should repeat this process 4 times; once for each router as I need to see whether these 20 clients are connected to that router or not.
My code needs to echo for example " the connection xxxx is reachable from the host yyyy".
Note: Hostname is an array of client-host names. (not IPs)
Aucun commentaire:
Enregistrer un commentaire