3

I have a strange issue with DNS resolving: Root of the problem is that I get curl errors: "Error executing HTTP request: name lookup timed out". Tried to ping some sites, all resolved fine (and fast). When trying Lynx with the same sites, some resolve really, really slow. Using Debian Wheezy. Now tried gethostbyname() in a PHP script, and that worked without problems. Why is the resolve fast with ping/php but extremely slow with Lynx/curl (curl ran from php). I had this issue some months ago but since then it was working, until now.

  • I tried adding a hostname/ip to /etc/hosts, that made that specific host resolve in php/curl and lynx... – Floddy Feb 13 '14 at 10:58
  • Are you using a proxy? What does echo $http_proxy say? If we can't find the problem otherwise, it may help to see a trace of what's going on behind the scenes: output of strace ping -c 1 example.com (which must be executed as root) and of strace curl http://example.com/, where example.com is a site that demonstrates the problem. – Gilles Feb 13 '14 at 18:49
1

You probably have a caching name server somewhere between. The first time you do the DNS query there's a delay since it's going out into the internet to get the DNS lookup details, subsequent lookup requests are cached and are serviced fairly quickly in comparison to the initial query.

dig with the +dnssearch oprion may help you diagnose and show you TTL (Time to live) values of the DNS records, which indicates when their cache's will expire, so that you know when you can attempt a virgin DNS request again, to verify longer timings.

When you changed /etc/hosts (thus by-passing internet DNS lookup) it sort of confirms above.

  • The weird thing is disregarding checking the site with lynx one time, the followint times the resolv is still as slow. dig +nssearch gives the wierd reply "reply from unexpected source" and "connection timed out; no servers could be reached". dig <sitename> gives a correct result directly. – Floddy Feb 13 '14 at 12:41

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.