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 ?

Pierre
  • 23
  • 4
  • 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 00: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 00:42
  • there’s a bit about it at https://unix.stackexchange.com/questions/78041/configuring-dns-resolver-failover-timeout#78042 . I don’t know if you can temporarily change it though. – Guy Jan 21 '18 at 00:52

1 Answers1

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)

Guy
  • 894
  • 1
  • 6
  • 20