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

1 Answers1

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.