2

I had a look at this existing post on the matter (What is the difference between ping -w and ping -W?), however either I don't understand what the ping -w flag is doing or it is just not working properly.

See below a ping command that takes more than 40 seconds to fail on my raspberry in spite of me trying to set a deadline of 1 second.

root@raspberrypi:~/scripts# time ping -c 1 -w 1 -W 1 www.google.com 
ping: www.google.com: Temporary failure in name resolution

real    0m40.064s 
user    0m0.010s
sys     0m0.020s

Any idea what I'm doing wrong ? or should I open a bug ?

3
  • 1
    Are those options actually going to affect anything if ping can’t get an ip? It looks like a dns issue, so ping won’t be sending any packets to be timed.
    – Guy
    Jan 21 '18 at 0:30
  • Thanks! Indeed that seems to be the problem here. When I replace the URL by an IP the flag seems to be effective. If you submit this as an anwer i will accept it. Am I the only one finding this behavior is unexpected (and fairly annoying)? When you want fail fast behavior, you usually also want to fail fast in case of DNS failure ; I don't see why this is handled differently.
    – Pierre
    Jan 21 '18 at 0:42
  • there’s a bit about it at unix.stackexchange.com/questions/78041/… . I don’t know if you can temporarily change it though.
    – Guy
    Jan 21 '18 at 0:52
1

The problem seems to be from resolving the url to an ip:

ping: www.google.com: Temporary failure in name resolution

So due to this, ping is not actually starting to send packets out, which is what is being timed, but waiting on a response to the dns request, which has a different timeout.

Sorting out the dns problems may help (or using the op directly, as you tried)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.