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 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 as its DNS lookup, how can it be the case that I can ping the IP but not the URL?


Here's the output of dig:

➜  dig @ www.google.com

; <<>> DiG 9.11.3-1ubuntu1.11-Ubuntu <<>> @ 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

; EDNS: version: 0, flags:; udp: 512
;www.google.com.                        IN      A

www.google.com.         297     IN      A

;; Query time: 21 msec
;; WHEN: Thu Aug 20 19:52:43 BST 2020
;; MSG SIZE  rcvd: 59


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:



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

  • just a note, is not google.com... at least not the page you are thinking... It is dns.google.com... google.com would be the IP returned in the dig - Though, the fact remains that you still cannot ping google.com... So does google.com even allow pings? I'm not able to test that from my location.
    – WU-TANG
    Aug 20, 2020 at 19:19
  • Yes @WU-TANG I can ping google.com when all is working normally.
    – LondonRob
    Aug 21, 2020 at 0:34
  • random tests: is it only google.com? try yahoo.com or askubuntu.com. Does it only get fixed when you mess with it? Leave an open ping with sound ping -a yahoo.comand go about your day, until you hear it, then rush back and check your logs to see if anything just registered. Look at the traffic sudo tcpdump -n port 53 is the traffic going out without a return? netstat -acpn | grep ":53" shows if a stub listener is running, if so, you'd probably have to sudo tcpdump -ni lo port 53 to watch the requests the stub us handling. Wired connection behavior? Static IP? right after reboot?
    – WU-TANG
    Aug 21, 2020 at 1:42
  • @WU-TANG Thanks for sticking with this mysterious and very annoying problem. Next time it happens I'll try all these things. (I like the idea of ping actually making a ping sound. Didn't know that was an option.)
    – LondonRob
    Aug 26, 2020 at 10:06
  • @WU-TANG added netstat and tcpdump outputs.
    – LondonRob
    Sep 2, 2020 at 14:34

5 Answers 5



dig @ 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)

  • Thanks Sph! It didn't happen this morning, but next time it does, I'll try this. Didn't know about dig. Care to add anything to your answer which puts what dig does and why it'd be useful to know its output?
    – LondonRob
    Jul 17, 2020 at 8:42
  • I can now confirm that this dig command works when dns doesn't work! Looks like you're onto something...
    – LondonRob
    Jul 31, 2020 at 10:06
  • This might've been a one-off but last time this happened, I found an IP address from dig, put it into my browser and the whole DNS thing sprang into life. Not sure which logs to look in to see what had changed, but I'll try it again next time it happens.
    – LondonRob
    Sep 13, 2020 at 14:34

It might be related to conflicts between the ancient system (ifupdown) and the new system (netplan,cloud-init,etc..). To only correct answer I could find to this modern nonsense was to :

apt remove ifupdown
apt install cloud-init
# comment out settings in /etc/network/interfaces
# complete settings in /etc/netplan/config.yaml

# Apply settings or reboot
netplan apply

The removal of ifupdown is needed to make the DNS resolver function properly.

[nb: my original post here: https://askubuntu.com/a/1255405/45849]

  • I don't really understand what cloud-init has to do with this solution. Is it related?
    – LondonRob
    Nov 16, 2020 at 12:31
  • @LondonRob It is related to netplan, and installed by default on ubuntu 18.04.
    – JB.
    Nov 17, 2020 at 7:07

Have you tried disabling systemd-resolved and then checking how the resolution works? I had problems in the past with it.

sudo systemctl disable systemd-resolved
sudo systemctl stop systemd-resolved

Then in the [main] section of your /etc/NetworkManager/NetworkManager.conf


Delete symlink to resolv.conf

rm /etc/resolv.conf

And then restart

sudo systemctl restart NetworkManager

I managed to get past this problem by forcing resolved to use a particular DNS server.

Previously, my resolv.conf was linked to /run/systemd/resolve/stub-resolv.conf:

$ l /etc/resolv.conf
lrwxrwxrwx 1 root root 39 Mar 30 10:32 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf

This contained the following:

options edns0

(It also has a lot of comments about how the file is autogenerated and not to mess with it manually. I don't know how it got generated like that.)

So I created a separate resolv.conf file, with:

options edns0

and replaced my symlink. Then restarted the service with:

sudo systemctl restart systemd-resolved

and suddenly it all sprang into life.


you do not need to dictate DNS address. Since the DNS toggle is switched to automatic you can leave the field empty.

  • 1
    Hi! Can you explain what this means? Which field? What's a DNS toggle? Why does it mean I can leave the DNS unspecified?
    – LondonRob
    Apr 1, 2021 at 9:50
  • This means your machine will automatically mimic the internet provider's DNS. Once you are connected to internet access.in most cases this results to 0r which are both google DNS servers. Apr 9, 2021 at 9:30
  • DNS Toggle refers to the button where yo switch on the DNS to automatic mode on and off.. and yes you can leave the DNS unspecified Apr 9, 2021 at 9:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .