Babar Haq

Saturday, May 27, 2006

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.

1 Comments:

  • you know...I was thinking of doing the same thing, but then I went out for lunch...

    Hee Hee...

    By Blogger Mohican, At 10:17 PM  

Post a Comment

Subscribe to Post Comments [Atom]



<< Home