Checking network connectivity from a linux box
I wrote a small bash script to check network connectivity from a linux box using ping. This solutions is available over the net so I am just reiterating it.
#!/bin/bash
if ( ping -c 1 -w 1 hostname/ip) &>/dev/null; then
echo "hostname/ip is up"
else
echo "hostname/ip is down"
fi
All you have to do is replace the hostname/ip with the system to whom you want to check your network connectivity. Beware! if you are using hostname, the ping will show the host down, even if it cannot resolve the hostname.
#!/bin/bash
if ( ping -c 1 -w 1 hostname/ip) &>/dev/null; then
echo "hostname/ip is up"
else
echo "hostname/ip is down"
fi
All you have to do is replace the hostname/ip with the system to whom you want to check your network connectivity. Beware! if you are using hostname, the ping will show the host down, even if it cannot resolve the hostname.