You are not logged in.

#1 2019-12-05 05:58:44

hyou
Member
Registered: 2019-09-23
Posts: 6

dig is fast but getent is slow

For some domains on my network, both `getent hosts` and browser resolution (`gethostbyname` I suppose) are super slow (10+ second) when I'm using 8.8.8.8 (this doesn't happen on OpenDNS). However, `dig` takes only several hundred ms, even though they're supposedly querying from the same DNS server.

How do I start to diagnose?

Last edited by hyou (2019-12-05 06:00:35)

Offline

#2 2019-12-05 09:28:17

seth
Member
Registered: 2012-09-03
Posts: 60,787

Re: dig is fast but getent is slow

dig doesn't use nsswitch, so esp. because of "domains on my network" it's one of the other confiured resolvers.
Also: do you use systemd-resolved?

Offline

#3 2019-12-05 13:40:54

hyou
Member
Registered: 2019-09-23
Posts: 6

Re: dig is fast but getent is slow

Sorry my wording was a bit confusing. I meant when I'm connected to this particular network and querying this particular (public) domain, it is slow with `getent hosts` and gethostbyname.

I'm using systemd-resolvd.

Offline

#4 2019-12-05 15:00:11

seth
Member
Registered: 2012-09-03
Posts: 60,787

Re: dig is fast but getent is slow

You could

strace getent hosts google.com

to see where it hangs.
Wild guess: IPv4 ./. IPv6 thing?

Offline

#5 2023-09-30 08:12:45

kode54
Member
Registered: 2013-10-21
Posts: 42

Re: dig is fast but getent is slow

Sorry to bump an old topic, but Google found this readily. I'm having the same lag problem with `getent hosts` resolving public IP addresses back to hostnames. If they're supposed to return NXDOMAIN, the resolver gets hung up for 5 seconds, each time.

strace shows the hang is entirely on waiting for Avahi to respond with a result.

For example, for resolving the reverse of the current kode54.net, my hosted domain:

connect(3, {sa_family=AF_UNIX, sun_path="/var/run/avahi-daemon/socket"}, 110) = 0
fcntl(3, F_GETFL)                       = 0x2 (flags O_RDWR)
newfstatat(3, "", {st_mode=S_IFSOCK|0777, st_size=0, ...}, AT_EMPTY_PATH) = 0
write(3, "RESOLVE-ADDRESS <public IP>\n", 30) = 30
read(3, "

5 second hang with cursor on the end of that line, then emitting the rest below:

-15 Timeout reached\n", 4096)  = 20
close(3)                                = 0

Further edit: It seems it was because something had convinced me to setting full `mdns` in nsswitch.conf instead of `mdns_minimal`.

Last edited by kode54 (2023-09-30 08:21:35)

Offline

#6 2023-09-30 13:07:26

seth
Member
Registered: 2012-09-03
Posts: 60,787

Re: dig is fast but getent is slow

Convinced by https://wiki.archlinux.org/title/Avahi# … om_working ?
Is resolved getting in the way/responding atm at all?

Offline

Board footer

Powered by FluxBB