You are not logged in.

#1 2021-11-04 09:30:37

arthurw
Member
Registered: 2019-09-03
Posts: 24

[Solved] DNS lookups are very slow

On my company laptop and my private laptop at home some DNS lookups are very slow. Hotspot with my iPhone is working perfekt an no DNS lookups are slow.
Both machines run arch linux and download rate should be fine.
I have noticed very slow ping response. It is not the ping times, which are actually fine, it is the first response to the request which seems to take a while
Some DNS lookups are quick but others are slow

Deactivating IPv6 did not help.
I allready stopped avahi-daemon.service because of
https://wiki.archlinux.org/title/avahi - Note: systemd-resolved has a built-in multicast DNS service, make sure to disable systemd-resolved's mDNS resolver/responder (refer to resolved.conf(5)) or disable systemd-resolved.service entirely before using Avahi.
and https://bbs.archlinux.org/viewtopic.php?id=58712
Which did not help.

/etc/nsswitch.conf: by default:
hosts: files mymachines myhostname resolve [!UNAVAIL=return] dns

example:

$ time ping -c2 bbc.co.uk
PING bbc.co.uk (151.101.192.81) 56(84) bytes of data.
64 Bytes von 151.101.192.81 (151.101.192.81): icmp_seq=1 ttl=55 Zeit=3.35 ms
64 Bytes von 151.101.192.81 (151.101.192.81): icmp_seq=2 ttl=55 Zeit=3.67 ms

--- bbc.co.uk ping statistics ---
2 Pakete übertragen, 2 empfangen, 0% packet loss, time 1130ms
rtt min/avg/max/mdev = 3.348/3.509/3.670/0.161 ms

real	0m17,011s
user	0m0,009s
sys	0m0,006s

$ time ping -c2 151.101.64.81
PING 151.101.64.81 (151.101.64.81) 56(84) bytes of data.
64 Bytes von 151.101.64.81: icmp_seq=1 ttl=55 Zeit=3.76 ms
64 Bytes von 151.101.64.81: icmp_seq=2 ttl=55 Zeit=4.95 ms

--- 151.101.64.81 ping statistics ---
2 Pakete übertragen, 2 empfangen, 0% packet loss, time 1002ms
rtt min/avg/max/mdev = 3.759/4.354/4.949/0.595 ms

real	0m1,017s
user	0m0,004s
sys	0m0,007s

Any suggestions?

Last edited by arthurw (2021-11-09 09:55:21)

Offline

#2 2021-11-04 10:10:35

Piri
Member
Registered: 2018-06-02
Posts: 69

Re: [Solved] DNS lookups are very slow

Do you use the DNS server assigned via DHCP or do you set one yourself? The DNS server of ISP consumer routers can be notoriously slow.  What's the output of

$ dig bbc.co.uk
$ dig @8.8.8.8 bbc.co.uk

?

Last edited by Piri (2021-11-04 10:13:43)

Offline

#3 2021-11-04 10:50:05

arthurw
Member
Registered: 2019-09-03
Posts: 24

Re: [Solved] DNS lookups are very slow

both, private: server assigned via DHCP and company set one by myself.

$ dig bbc.co.uk

; <<>> DiG 9.16.22 <<>> bbc.co.uk
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 51965
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;bbc.co.uk.			IN	A

;; ANSWER SECTION:
bbc.co.uk.		300	IN	A	151.101.192.81
bbc.co.uk.		300	IN	A	151.101.0.81
bbc.co.uk.		300	IN	A	151.101.64.81
bbc.co.uk.		300	IN	A	151.101.128.81

;; Query time: 39 msec
;; SERVER: 10.10.30.1#53(10.10.30.1)
;; WHEN: Thu Nov 04 11:48:54 CET 2021
$ dig @8.8.8.8 bbc.co.uk

; <<>> DiG 9.16.22 <<>> @8.8.8.8 bbc.co.uk
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 7562
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;bbc.co.uk.			IN	A

;; ANSWER SECTION:
bbc.co.uk.		38	IN	A	151.101.0.81
bbc.co.uk.		38	IN	A	151.101.64.81
bbc.co.uk.		38	IN	A	151.101.128.81
bbc.co.uk.		38	IN	A	151.101.192.81

;; Query time: 13 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Thu Nov 04 11:49:51 CET 2021
;; MSG SIZE  rcvd: 102

Offline

#4 2021-11-04 12:26:39

Piri
Member
Registered: 2018-06-02
Posts: 69

Re: [Solved] DNS lookups are very slow

Yeah, scratch that idea.

arthurw wrote:

I allready stopped avahi-daemon.service because of
https://wiki.archlinux.org/title/avahi - Note: systemd-resolved [...]

;; SERVER: 10.10.30.1#53(10.10.30.1)

Are/Were you even using systemd-resolved, what's your network configuration?

Offline

#5 2021-11-04 12:52:03

seth
Member
Registered: 2012-09-03
Posts: 25,086

Re: [Solved] DNS lookups are very slow

"Both" means a cascade, the second one is used if the first one doesn't reply.

stat /etc/resolv.conf
cat /etc/resolv.conf

The 39ms dig is actually not bad (just not cached, *sigh*) - is it slow despite as well?
If not, what about

nslookup bbc.co.uk
getent hosts bbc.co.uk
drill bbc.co.uk # drill is particularily interesting as it doesn't use libnss

And as a sanity check, make 8.8.8.8 (google) or 1.1.1.1 (cloudflare) your primary DNS and see whether DNS is still slow.

Offline

#6 2021-11-04 14:02:15

arthurw
Member
Registered: 2019-09-03
Posts: 24

Re: [Solved] DNS lookups are very slow

I started avahi again.
And i am even using systemd-resolved.
For testing i did following changes:
"added the mdns_minimal to nsswitch.conf and turned mdns off for systemd-resolved in the configuration file and all interfaces "resolvectl mdns eth0 off" " see: https://archlinuxarm.org/forum/viewtopi … =9&t=14447
so i will test it...

The 39ms dig is actually not bad

The DMS Lookup is not always slow. Just often..

$ getent hosts bbc.co.uk
2a04:4e42::81   bbc.co.uk
2a04:4e42:200::81 bbc.co.uk
2a04:4e42:400::81 bbc.co.uk
2a04:4e42:600::81 bbc.co.uk
$ drill bbc.co.uk 
;; ->>HEADER<<- opcode: QUERY, rcode: NOERROR, id: 62685
;; flags: qr rd ra ; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 0 
;; QUESTION SECTION:
;; bbc.co.uk.	IN	A

;; ANSWER SECTION:
bbc.co.uk.	267	IN	A	151.101.64.81
bbc.co.uk.	267	IN	A	151.101.128.81
bbc.co.uk.	267	IN	A	151.101.192.81
bbc.co.uk.	267	IN	A	151.101.0.81

;; AUTHORITY SECTION:

;; ADDITIONAL SECTION:

;; Query time: 4 msec
;; SERVER: 10.10.31.99
;; WHEN: Thu Nov  4 14:59:18 2021
;; MSG SIZE  rcvd: 91

And as a sanity check, make 8.8.8.8 (google) or 1.1.1.1 (cloudflare) your primary DNS and see whether DNS is still slow.

no big changes

Last edited by arthurw (2021-11-04 14:26:18)

Offline

#7 2021-11-04 15:00:54

Piri
Member
Registered: 2018-06-02
Posts: 69

Re: [Solved] DNS lookups are very slow

Seth wrote:
stat /etc/resolv.conf
cat /etc/resolv.conf

Post these please aswell

Offline

#8 2021-11-04 15:13:35

arthurw
Member
Registered: 2019-09-03
Posts: 24

Re: [Solved] DNS lookups are very slow

$ stat /etc/resolv.conf
 Datei: /etc/resolv.conf
 Größe: 52        	Blöcke: 8          EA Block: 4096   reguläre Datei
Device: 254,2	Inode: 24381092    Links: 1
Zugriff: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Zugriff: 2021-11-04 15:26:01.584921192 +0100
Modifiziert: 2021-11-04 15:26:01.564921458 +0100
Geändert: 2021-11-04 15:26:01.568254746 +0100
Geburt: 2021-11-04 15:26:01.564921458 +0100
cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 10.10.30.1

Offline

#9 2021-11-04 19:04:05

karloff
Member
Registered: 2021-11-02
Posts: 2

Re: [Solved] DNS lookups are very slow

Please post output of

time drill @8.8.8.8 A ccc.de
time drill @10.10.30.1 A ccc.de

or use dig if you have it

time dig ccc.de @10.10.30.1
time dig ccc.de @8.8.8.8

and maybe you want to do a "export LANG=C" for the none german people here

Offline

#10 2021-11-05 08:54:52

arthurw
Member
Registered: 2019-09-03
Posts: 24

Re: [Solved] DNS lookups are very slow

Another machine same problem.

$ time dig ccc.de @8.8.8.8

; <<>> DiG 9.16.22 <<>> ccc.de @8.8.8.8
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 13505
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;ccc.de.				IN	A

;; ANSWER SECTION:
ccc.de.			7046	IN	A	195.54.164.39

;; Query time: 53 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Fri Nov 05 09:52:04 CET 2021
;; MSG SIZE  rcvd: 51


real	0m0,073s
user	0m0,004s
sys	0m0,007s

Sorry for german outputs.
i am testing the "added the mdns_minimal to nsswitch.conf and turned mdns off for systemd-resolved in the configuration file and all interfaces "resolvectl mdns eth0 off" changes and see whats happens.
the machine with the 10.10.30.1 DNS Server i am able to test on tuesday again.

Last edited by arthurw (2021-11-05 08:56:04)

Offline

#11 2021-11-05 11:43:40

seth
Member
Registered: 2012-09-03
Posts: 25,086

Re: [Solved] DNS lookups are very slow

;; Query time: 53 msec
real	0m0,073s

53ms query (and 73ms) isn't awesome (I get 20-30ms responses from 8.8.8.8) but not indicative of a problem (the initial post had a 16 SECONDS overhead…)

time dig ccc.de
time getent hosts ccc.de
stat /etc/resolv.conf
cat /etc/resolv.conf
cat /etc/nsswitch.conf

Offline

#12 2021-11-05 12:16:24

arthurw
Member
Registered: 2019-09-03
Posts: 24

Re: [Solved] DNS lookups are very slow

Thanks for your help. I will test my changes and give feedback on tuesday.
The DNS lookups are not always slow, but often and it depends on no host.

Offline

#13 2021-11-05 12:20:37

seth
Member
Registered: 2012-09-03
Posts: 25,086

Re: [Solved] DNS lookups are very slow

I suspect that the default DNS (we don't know about the one used by "another machine") is just overloaded and you've not indicated to have or will change it to cloudflare or google to test that.
So make sure to do so.

Offline

#14 2021-11-05 13:00:09

arthurw
Member
Registered: 2019-09-03
Posts: 24

Re: [Solved] DNS lookups are very slow

Thanks i'll test that again. but yesterday there where no big changes with the google dns server

Last edited by arthurw (2021-11-05 13:00:29)

Offline

#15 2021-11-09 09:54:49

arthurw
Member
Registered: 2019-09-03
Posts: 24

Re: [Solved] DNS lookups are very slow

I think the solution is described in: https://archlinuxarm.org/forum/viewtopi … =9&t=14447
"added the mdns_minimal to nsswitch.conf and turned mdns off for systemd-resolved in the configuration file and all interfaces "resolvectl mdns eth0 off" "
i could not reproduce the problem again until now. if there are very long dns lookups again, i will reopen the issue. Thanks to all for your quick help.

Offline

Board footer

Powered by FluxBB