Ubuntu – Very slow DNS lookup

16.04dnsnetwork-managernetworking

I'm on Ubuntu 16.04 LTS, and when I visit a website/curl/wget/ping/etc anything that isn't an IP address, it takes an annoyingly long time (> 5 s), whereas anything directly using an IP address is pretty much instant (< 10 ms, as one would expect).

When I cat /etc/NetworkManager/NetworkManager.conf, I get:

[main]
plugins=ifupdown,keyfile,ofono
dns=dnsmasq

[ifupdown]
managed=false

I've tried changing to #dns=dnsmasq, but it didn't have any noticeable effect.

cat /etc/network/interfaces is also quite basic:

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

A bit odd is cat /etc/resolv.conf:

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN

nameserver 10.63.240.10
nameserver 127.0.1.1
search $companydomain$.com

The nameserver 10.63.240.10 is something a colleague doesn't have, and is the only way in which the above 3 files differ for us.
I suspect that is the root of the issue, because when I do host www.stackexchange.com 10.63.240.10, I get:

;; connection timed out; no servers could be reached

Commenting it out and restarting the network-manager fixes the issue temporarily, only to return upon rebooting.

I've also noticed in the Network Connections menu, two (seemingly) auto-generated Bridge entries are listed: br-8f98800bd128 and br-bd749c12d64c.
If I delete these, they're back after a reboot. My aforementioned colleague doesn't have these either.

I've also tried the suggestions from How do I configure my DNS settings in Ubuntu server? and Extrememly slow DNS lookup, but the issue remains.

Per M. Becerra's suggestion, I ran sudo updatedb; locate 10.63.240.10. This didn't give me any output.

Mikael Schultz suggested I do nmcli device show, which outputs:

GENERAL.DEVICE:                         br-8f98800bd128
GENERAL.TYPE:                           bridge
GENERAL.HWADDR:                         02:42:50:5E:58:3B
GENERAL.MTU:                            1500
GENERAL.STATE:                          100 (connected)
GENERAL.CONNECTION:                     br-8f98800bd128
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/2
IP4.ADDRESS[1]:                         172.18.0.1/16
IP4.GATEWAY:                            
IP6.GATEWAY:                            

GENERAL.DEVICE:                         br-bd749c12d64c
GENERAL.TYPE:                           bridge
GENERAL.HWADDR:                         02:42:B1:85:6D:E3
GENERAL.MTU:                            1500
GENERAL.STATE:                          100 (connected)
GENERAL.CONNECTION:                     br-bd749c12d64c
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/3
IP4.ADDRESS[1]:                         172.19.0.1/16
IP4.GATEWAY:                            
IP6.GATEWAY:                            

GENERAL.DEVICE:                         docker0
GENERAL.TYPE:                           bridge
GENERAL.HWADDR:                         36:CA:3D:66:B7:03
GENERAL.MTU:                            1500
GENERAL.STATE:                          100 (connected)
GENERAL.CONNECTION:                     docker0
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/1
IP4.ADDRESS[1]:                         172.17.0.1/16
IP4.GATEWAY:                            
IP6.GATEWAY:                            

GENERAL.DEVICE:                         wlp3s0
GENERAL.TYPE:                           wifi
GENERAL.HWADDR:                         00:28:F8:9C:2A:4D
GENERAL.MTU:                            0
GENERAL.STATE:                          100 (connected)
GENERAL.CONNECTION:                     Crowdynews
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/0
IP4.ADDRESS[1]:                         10.0.0.27/24
IP4.GATEWAY:                            10.0.0.1
IP4.ROUTE[1]:                           dst = 169.254.0.0/16, nh = 0.0.0.0, mt = 1000
IP4.DNS[1]:                             8.8.8.8
IP4.DNS[2]:                             8.8.4.4
IP4.DOMAIN[1]:                          crowdynews.com
IP6.ADDRESS[1]:                         fe80::9264:b967:1c59:3e50/64
IP6.GATEWAY:                            

GENERAL.DEVICE:                         enp4s0
GENERAL.TYPE:                           ethernet
GENERAL.HWADDR:                         C8:5B:76:F1:1C:EC
GENERAL.MTU:                            1500
GENERAL.STATE:                          20 (unavailable)
GENERAL.CONNECTION:                     --
GENERAL.CON-PATH:                       --
WIRED-PROPERTIES.CARRIER:               off

GENERAL.DEVICE:                         lo
GENERAL.TYPE:                           loopback
GENERAL.HWADDR:                         00:00:00:00:00:00
GENERAL.MTU:                            65536
GENERAL.STATE:                          10 (unmanaged)
GENERAL.CONNECTION:                     --
GENERAL.CON-PATH:                       --
IP4.ADDRESS[1]:                         127.0.0.1/8
IP4.GATEWAY:                            
IP6.ADDRESS[1]:                         ::1/128
IP6.GATEWAY:                            

ip address prints:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
   valid_lft forever preferred_lft forever
inet6 ::1/128 scope host 
   valid_lft forever preferred_lft forever
2: enp4s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
link/ether c8:5b:76:f1:1c:ec brd ff:ff:ff:ff:ff:ff
3: wlp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:28:f8:9c:2a:4d brd ff:ff:ff:ff:ff:ff
inet 10.0.0.27/24 brd 10.0.0.255 scope global dynamic wlp3s0
   valid_lft 1660731sec preferred_lft 1660731sec
inet6 fe80::9264:b967:1c59:3e50/64 scope link 
   valid_lft forever preferred_lft forever
4: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
link/ether 02:42:f3:cd:08:8c brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
   valid_lft forever preferred_lft forever
5: br-8f98800bd128: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
link/ether 02:42:50:5e:58:3b brd ff:ff:ff:ff:ff:ff
inet 172.18.0.1/16 brd 172.18.255.255 scope global br-8f98800bd128
   valid_lft forever preferred_lft forever
6: br-bd749c12d64c: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
link/ether 02:42:b1:85:6d:e3 brd ff:ff:ff:ff:ff:ff
inet 172.19.0.1/16 brd 172.19.255.255 scope global br-bd749c12d64c
   valid_lft forever preferred_lft forever

cat /etc/resolvconf/resolv.conf.d/head:

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN

nameserver 10.63.240.10

cat /etc/resolvconf/resolv.conf.d/base generates no output.

How do I fix this?

Best Answer

The problem seems to be that there is a faulty DNS server in the file /etc/resolvconf/resolv.conf.d/head.

Edit the head file and delete the line that says nameserver 10.63.240.10 and you should have solved your problem.

Run sudo nano /etc/resolvconf/resolv.conf.d/head from the Terminal to edit the file and make sure that the only content of the file is:

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN

Hope this solves your problem.

Related Question