The ping man page states : " If ping does not receive any reply packets at all it will exit with code 1. On error it exits with code 2. Otherwise it exits with code 0. This makes it possible to use the exit code to see if a host is alive or not." The current (RH 6.1) ping does not return a non-zero exit code for unreachable hosts : aqua:akonstan> rpm -qf /bin/ping netkit-base-0.10-37 aqua:akonstan> /bin/ping -c 1 128.59.22.1 PING 128.59.22.1 (128.59.22.1) from 128.59.22.27 : 56(84) bytes of data. From aqua.cs.columbia.edu (128.59.22.27): Destination Host Unreachable --- 128.59.22.1 ping statistics --- 1 packets transmitted, 0 packets received, +1 errors, 100% packet loss aqua:akonstan> echo $? 0 aqua:akonstan> uname -a Linux aqua.cs.columbia.edu 2.2.12-20 #1 Mon Sep 27 10:40:35 EDT 1999 i686 unknown
This bug has been fixed in iputils version 000305.
Upgrade to the inetd/ping packages from Raw Hide, all known problems with ping are fixed there. Note carefully that recent versions of Red Hat have changed the "-c <packets>" to count received (not transmitted) packets, so you will need to use "-w <secs>" if using ping to test reachability of hosts that may be down.