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)... 18.104.22.168, 22.214.171.124, 126.96.36.199, ... Connecting to www.google.com (www.google.com)|188.8.131.52|: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  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 184.108.40.206 nameserver 220.127.116.11 nameserver 18.104.22.168
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: 22.214.171.124 Address: 126.96.36.199#53 Non-authoritative answer: Name: www.google.com Address: 188.8.131.52 Name: www.google.com Address: 184.108.40.206 Name: www.google.com Address: 220.127.116.11 Name: www.google.com Address: 18.104.22.168 Name: www.google.com Address: 22.214.171.124 Name: www.google.com Address: 126.96.36.199 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 188.8.131.52 184.108.40.206 127.0.0.1 but that makes the other nameservers disappear upon networking restart.