Ping takes 20s to start

Laptop: Thinkpad W520, running Manjaro KDE. Connected on wifi 2.4GHz

This has started to happen quite suddenly. My service provider upgraded me to an optic fiber router. Windows PCs and my own dual-boot laptop on Windows (ugh) ping etc quite fine, but when I type ping in a Manjaro terminal it hangs for about 20 seconds and then pings normally. The browser upon opening the first time takes a similar time to connect to, subsequent accesses are quick. Name resolution lookup issue for sure, since pinging google’s IP address works fine. Where should I look for name resolution issues?

Additionally - I find that even before connecting to wifi upon bootup I get a notification saying “this machine appears to be connected to a network but is unable to reach the internet.” This may provide an important clue. I would not get such a notification earlier if I was not logged into any network.

Thank you!
Best - Ram

What’s the content of your /etc/resolv.conf file?

As below - is the LAN address of my optical broadband router where the ISP comes in.

# Generated by NetworkManager
search Home

Manjaro defaults to using openresolv (resolvconf) for lookups.

By experience I can recommend to switch to systemd-resolved.

The switch is faily simple - actually like 1-2-3

  1. Enable and start systemd-resolved
    sudo systemctl enable --now systemd-resolved
  2. Rename /etc/resolv.conf
    sudo mv /etc/resolv.conf /etc/resolv.conf.bak
  3. Symlink the systemd stub-resolv to /etc/resolv.conf
    sudo ln -s /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf

Reload your NetworkManager

sudo systemctl reload NetworkManager

Then test your lookup again - if it don’t give the expected result, it is easily reversed.

1 Like

I tried this and it did not solve the lookup delay problem…Should I revert to openresolv or is it better to continue down this path and fix something else now?
Best - Ram

You probably mean:

sudo ln -s /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf

Thanks…I just realized the link had gone to my home folder. I tried creating the symlink again but the ping still takes forever. The new resolv.conf reads as follows. Maybe it should have a real DNS in it? Let me try.

options edns0 trust-ad
search Home

Install the bind package (if not already installed) and execute this:

dig @

Probably a DNS change should solve the problem, but why your modem’s DNS server is taking so much time to answer?

Let me again recall the fact that my modem is almost certainly not the culprit because names resolve instantly from other computers on the network, including my own laptop when I’m booted into the other stupid OS. The problem has got to be within Manjaro settings.
Meanwhile I tried setting the nameserver to but lookups still take forever

Try the dig command and let’s see if it gives us some clue.

Also if ping your modem, does it answer right away?


Installing bind as I type (taking forever since each lookup by the software manager takes forever!)
pinging (my modem/router) gets an instant reply.

What also can come to my mind is that DNS server is resolving in IPv6 but IPv6 is not working on your network and after the timeout it continues in IPv4.

Let’s see if there is any change with:

ping -4

I had tried that earlier, tried again now…no difference.

Here is what it tells me.

[ramkumarr@RR-W520 ~]$ dig @

; <<>> DiG 9.16.20 <<>> @
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 30920
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

; EDNS: version: 0, flags:; udp: 4096
; IN A


;; Query time: 9 msec
;; WHEN: Thu Sep 16 15:01:52 IST 2021
;; MSG SIZE rcvd: 55

[ramkumarr@RR-W520 ~]$

Doh - you are correct :man_facepalming: - fixed.

When bind-tools was put into the package bind - I discovered the drill command - it works like the bind-util dig and it comes default on Arch based distributions.

What is especially interesting here is the last couple of lines with the response time from name service and 9msec is definately good.

1 Like

The times you get from dig or drill can’t compared with lookup times form most other applications.

The problem is that drill will directly ask the DNS Server listed in /etc/resolv.conf . Normal programs that use glib (which most programs do) will not do that. It will go thru the NSS (Name Service Switch). If systemd-resolved is used it will never go thru /etc/resolv.conf . If systemd-resolved is not active, it will used by the glibc resolver and passed back thru the liabary.

However, to determine the resolve time, it is better to use a tool, that uses the same path. For example curl.

curl -o /dev/null -s -w "%{time_namelookup}\n"

The output will be the time it took to get the namelookup in seconds. You might want to use a domain that is never used before or you might get a cache hit.

1 Like

You are right about the cache issue. With systemd resolver you can flush the cache using

resolvectl flush-caches

Then retest


Tried both. Here are the outputs. I find that since I made the switch to systemd-resolved, the iping times have actually increased considerably and now it’s almost as if I cannot access the Internet. Lookup times “seem to be” a bit better when I am using my phone’s hotspot (as I am doing now to access this forum). It’s quite unbearable. Can I just reinstall Network manager or something :stuck_out_tongue: ?

[ramkumarr@RR-W520 ~]$ resolvectl flush-caches
[ramkumarr@RR-W520 ~]$ drill
;; ->>HEADER<<- opcode: QUERY, rcode: NOERROR, id: 25110
;; flags: qr rd ra ; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 
;;  IN      A

;; ANSWER SECTION:     242     IN      A



;; Query time: 7 msec
;; WHEN: Thu Sep 16 16:50:50 2021
;; MSG SIZE  rcvd: 44
[ramkumarr@RR-W520 ~]$ curl -o /dev/null -s -w "%{time_namelookup}\n"
[ramkumarr@RR-W520 ~]$
[ramkumarr@RR-W520 ~]$ curl -o /dev/null -s -w "%{time_namelookup}\n" >
[ramkumarr@RR-W520 ~]$ curl -o /dev/null -s -w "%{time_namelookup}\n"
[ramkumarr@RR-W520 ~]$

(Never accessed the last one.)

After you have flushed systemd resolver cache - you have a 7ms response from the nameservice for

That is nowhere near 20s and within acceptable margin :slight_smile:

And the others are acceptable as well.

I am sure there is something else going on - because it is not your lookups which is at fault here.

You have to look elsewhere - go back in history - do you have a reference point where you know the system worked?

Is it an app you have installed?

What changes have you made which may interfere with the network?

The package pacmanlogviewer is nice tool to filter the pacman log.

sudo pacman -S pacmanlogviewer

Now here is what is very funny - I booted into a Manjaro live USB - and I have the exact same problem - ping takes approx 20 seconds to respond. Websites take that long to connect to. Again - this problem on the same laptop booted into Windoze does not occur. I am quite lost here.