1

When I try to do a wget of http://www.google.com on my Raspberry Pi, I don't get a response for over 6 seconds, almost all of which is while the output below is stuck on "Resolving www.google.com (www.google.com)..."

$ time wget http://www.google.com
--2016-12-09 16:39:57--  http://www.google.com/
Resolving www.google.com (www.google.com)... 74.125.68.103, 74.125.68.99, 74.125.68.105, ...
Connecting to www.google.com (www.google.com)|74.125.68.103|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘index.html’

index.html                                            [ <=>                                                                                                           ]  10.67K  --.-KB/s   in 0.009s 

2016-12-09 16:40:03 (1.13 MB/s) - ‘index.html’ saved [10922]


real    0m5.707s
user    0m0.010s
sys     0m0.020s

This suggests a DNS problem. I tried to troubleshoot this by adding a timeout to my /etc/resolv.conf, and commenting out my local 192.168.1.1 server, but it makes no difference in the delays:

$ cat /etc/resolv.conf 
# Generated by resolvconf
option timeout: 5
domain domain_not_set.invalid
#nameserver 192.168.1.1
nameserver 4.2.2.2
nameserver 8.8.8.8
nameserver 8.8.4.4

When I try to do a nslookup by itself, it comes back without delay. See below.

What possibly could be going wrong?

$ time nslookup www.google.com
Server:     4.2.2.2
Address:    4.2.2.2#53

Non-authoritative answer:
Name:   www.google.com
Address: 74.125.200.105
Name:   www.google.com
Address: 74.125.200.103
Name:   www.google.com
Address: 74.125.200.104
Name:   www.google.com
Address: 74.125.200.106
Name:   www.google.com
Address: 74.125.200.147
Name:   www.google.com
Address: 74.125.200.99


real    0m0.063s
user    0m0.030s
sys     0m0.000s

EDIT: Rebooting my home router makes no difference. And other clients on the network (e.g. my MacBook Pro and my mobile phone) have no similar delays when browsing the web.

EDIT: I found a kludge that fixes this by installing sudo apt-get install bind9 and then adding nameserver 127.0.0.1 to the top of /etc/resolv.conf. I found this suggestion at this link, which suggests this is an IPV6 issue. However, this is not a good solution, because each time I reboot, my /etc/resolv.conf gets regenerated, my added line gets removed, and my problem returns. I tried adding 127.0.0.1 to /etc/network/interfaces with dns-nameservers 8.8.8.8 8.8.4.4 127.0.0.1 but that makes the other nameservers disappear upon networking restart.

migrated from raspberrypi.stackexchange.com Dec 9 '16 at 17:28

This question came from our site for users and developers of hardware and software for Raspberry Pi.

  • When I try that wget... I get a 302 Found redirect to www.google.co.uk. I wonder if the reason getting your web page is slow is because your IP address doesn't have a GeoIP lookup so Google doesn't know where (or if) to redirect you. It might be worth trying the whois {your_ip_address} game. (For an IP address of 1.2.3.4 you'd try whois 1.2.3.4. If you don't get a sensible answer then try whois 1.2.3.0. If that's nonsense try whois 1.2.0.0.) On the other hand I don't see why that should delay the lookup six seconds. – roaima Dec 10 '16 at 0:31
1

Remove nameserver 4.2.2.2 from your list of domain servers.

Unless you're a Level 3 customer, in which you case you need to contact them directly to ask why name resolution is slow.

  • Thanks for the tip. Unfortunately, commenting out 4.2.2.2 from my /etc/resolv.conf does not change the resolution delay when using wget, although it does change the server used when I use nslookup: $ time nslookup www.google.com Server: 8.8.8.8 Address: 8.8.8.8#53 Non-authoritative answer: Name: www.google.com Address: 216.58.217.132 real 0m0.071s user 0m0.030s sys 0m0.000s – davidgyoung Dec 9 '16 at 20:53

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.