Ubuntu – No DNS lookup with Google’s DNS servers

18.04dnsnetworking

Some mornings when my Ubuntu 18.04 wakes from hibernate, it takes around 30 minutes before I can do any DNS lookups.

I already disabled automatic DNS and added Google's DNS servers instead:

DNS Settings

How I set up Google's DNS servers

But nevertheless, I can ping 8.8.8.8 but not google.com:

can't ping Google

Usually after much fruitless enabling/disabling Wifi, and connect and disconnecting Wifi networks, it suddenly springs into action and all is well for the rest of the day.

But here's the mystery: if Ubuntu is using 8.8.8.8 as its DNS lookup, how can it be the case that I can ping the IP but not the URL?

dig

Here's the output of dig:

➜  dig @8.8.8.8 www.google.com

; <<>> DiG 9.11.3-1ubuntu1.11-Ubuntu <<>> @8.8.8.8 www.google.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 39427
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;www.google.com.                        IN      A

;; ANSWER SECTION:
www.google.com.         297     IN      A       216.58.206.100

;; Query time: 21 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Thu Aug 20 19:52:43 BST 2020
;; MSG SIZE  rcvd: 59

tcpdump

sudo tcpdump -ni lo port 53

This command showed nothing until about 20 minutes after booting up, at which point it exploded into life with things like:

tcpdump

netstat

netstat -acpn | grep ":53"

This is the output of netstat when DNS lookup isn't working.

netstat no DNS output

And with DNS working, later in the day:

netstat with DNS output

Best Answer

  • Try

    dig @8.8.8.8 www.ubuntu.com
    

    just to rule out that DNS traffic somehow gets mangled.

    edit: dig is a tool to query DNS-Servers. By using the the @serverIP syntax you can bypass the systems DNS settings and directly talk to a DNS server of your choice. IMHO this helps a lot in diagnosing if the problem is your machine (dig with @syntax working) or on the network side (dig with @syntax returning the same result)

  • Related Question