Description of Problem: Two things (maybe more) have changed about the 'ping' command that break some shell scripts. 1. It's exit code seems to be the same regardless of whether or not it could ping the desired host. 2. When using the '-cN' option, ping will not exit after N packets have been sent and timed out. I've been using the -w option instead, but it's really not the same. In general it seems like quite a few command-line options have changed since we upgraded from RedHat 7.1. Version-Release number of selected component (if applicable): iputils-ss020124 How Reproducible: 100% Steps to Reproduce: 1. if ping -w5 somehost > /dev/null 2>&1; then echo true; fi 2. In my experience the above will always print "true" regardless of whether or not somehost is alive. 3. This makes it harder to write shell scripts which ping a host to see if it's alive before performing some action. Actual Results: Expected Results: Additional Information: Please contact me if you need more info.
*** Bug 69282 has been marked as a duplicate of this bug. ***
Use ping -c1 -w1 nonexistent_host to have ping check for an host being up or down without hanging and with correct exit status.
*** Bug 77685 has been marked as a duplicate of this bug. ***
ping -c1 -w1 nonexistenthost does in fact do the job. (Funny, I thought I tested that before and it didn't work ... I must be hallucinating). It would still be nice for ping -w1 nonexistenthost to return the correct exit value, too. ("success" should be determined by any packets coming back from the host, regardless of if you force the number of packets sent to a specific value.) As a nitpick, I suggest adding this example to the manpage -- there seem to be several other people that have run into this problem too. Also, how does the -c option work if -w is not also specified? Does it ever time out, or does it just take a very long time? Perhaps there should be an addition to the manpage under the -c descripttion that says "in practise this takes ages to time out so you probably want to specify -w also". Thank you very much for your help with this. I don't mean to complain too much, just offer constructive feedback so Linux can be even better.
If an ordinary user on our default RH8 install tries to ping a non existant address like 192.168.40.40 ping returns: From 217.37.xx.xxx icmp_seq=1 Destination Port Unreachable repeatedly, Trouble is if I run that for one second I get: --- 192.168.40.40 ping statistics --- 0 packets transmitted, 0 received, +6415 errors CPU Usage and Load continue to grow as resources permit. I gave up when my load average went through 3 having no desire to see what would break. I worry about the potential here for a local Denial of Service attack by anyone with a user account on the server.
This has been fixed in the current release. ping -c 1 will timeout again. Read ya, Phil