0

Why this big difference in times if the domain name is resolved by ping itself, versus getent externally?


$ time ping -c1 "google.com""
0% packet loss
0m5,064s

$ time (ip=$(getent ahostsv4 "google.es" | awk '{ print $1 }' |
head -n1); ping -c1 "${ip}")
0% packet loss
0m0,042s
4
  • time will tell how much time took the command to run, not how much time the ping took. If you ping <bogus ip>, time will tell you i.e. 10s, when there was never a real ping involved. Oct 23, 2019 at 22:52
  • That's what I meant, that time isn't the actual ping but the tool trying to solve the name. The difference in times doing that same thing is big. Oct 23, 2019 at 22:54
  • Try to run the commands several times in a row and you see that there's not a clear pattern... as far as I've tried. Oct 23, 2019 at 23:00
  • First case always takes more than 5s, second case always less than 100ms. Oct 23, 2019 at 23:03

1 Answer 1

3

A work-around that succeeded was, on /etc/resolv.conf, adding:

options single-request-reopen

Suggesting the root issue:

Sets RES_SNGLKUPREOP in _res.options. The resolver uses the same socket for the A and AAAA requests. Some hardware mistakenly sends back only one reply. When that happens the client system will sit and wait for the second reply. Turning this option on changes this behavior so that if two requests from the same port are not handled correctly it will close the socket and open a new one before sending the second request.

So disabling IPv6 on my Google Wifi router fixed the problem.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .