5

I got terribly slow dns resolve inside my ubuntu when using wget or curl, apt-get,...

root@815340a37f0e:/# time curl www.google.com
...
real    0m5.132s
user    0m0.006s
sys     0m0.003s

When I do nslookup its pretty fast.

root@815340a37f0e:/# time nslookup google.com
Server:         8.8.8.8
Address:        8.8.8.8#53

Non-authoritative answer:
Name:   google.com
Address: 173.194.78.101
...
real    0m0.024s
user    0m0.010s
sys     0m0.005s
svobol13
  • 163
  • 3
  • 6
  • 1
    Are you sure it's the DNS which is slow and not something else? Perhaps the MTU is wrong and causes your TCP traffic being much slower than it should be? Capture the traffic with tcpdump or wireshark and see how it goes. – Janne Pikkarainen Nov 26 '14 at 11:02
  • When I run `wget google.com`, `Resolving google.com (google.com)...` gets printed out and whole process waits like 5 seconds. After that `Resolving google.com (google.com)... 74.125.71.139, 74.125.71.113, 74.125.71.138, ...` IP addresses are appended and whole is instantly finished. So I guess problem is at the resolving stage. – svobol13 Nov 26 '14 at 14:54
  • What is in the container's `/etc/resolv.conf`? – Michael Hampton Nov 26 '14 at 17:04
  • @MichaelHampton `nameserver 8.8.8.8` I installed dnsmasq so lookups are cached atleast. Isn't 5seconds resolution time against `8.8.8.8` normal? – svobol13 Nov 26 '14 at 17:15
  • how long is it taking when you try `curl` with google's IP address like `time curl -L 173.194.78.101` and can you also provide the output of `ping 173.194.78.101`. – Kannan Mohan Nov 28 '14 at 11:12
  • resolving when curling and wgeting takes same time (~5seconds). Ping or nslookup are like instant (few milis). – svobol13 Nov 28 '14 at 14:33

1 Answers1

4

We had the same problem, and we found out that our hardware showed broken behaviour with IPv6.

You could double check with curl and force IPv4 like so:

$ time curl -4 www.google.com
...
real    0m0.074s
user    0m0.011s
sys     0m0.000s

Update 1:

We had the problem with our Windows Host System (Ubuntu 14.04 is the guest). The actual solution was found on this page.

Adding options single-request-reopen to the /etc/resolvconf/resolv.conf.d/base and running sudo resolvconf -h did the trick for us.

I found another anwser on askubuntu that suggested almost the same.

rene_gr
  • 141
  • 4