You find that DNS queries take a long time from your machine, and you decide to fix this by installing a local DNS resolver. You ask the internet, whi

Don't use `nscd`

submited by
Style Pass
2022-09-23 12:30:08

You find that DNS queries take a long time from your machine, and you decide to fix this by installing a local DNS resolver. You ask the internet, which says:

An ordinary DNS server listens on UDP port 53. When running a local caching DNS resolver, local processes will contact localhost:53 for any DNS lookups.

But, unlike the other caching DNS resolvers, nscd does not listen on any ports! Instead, nscd listens on a socket, /var/run/nscd/socket. How, though, do local processes know to connect to /var/run/nscd/socket?

The answer is that local processes don’t know to connect to /var/run/nscd/socket. Or rather, some do, and some don’t. The processes that do know about /var/run/nscd/socket are those linked against glibc and using getaddrinfo from that library.

Only GNU’s implementation of the C standard library has the knowledge of /var/run/nscd/socket. If your process is linked against a different libc (e.g. musl), or if your process uses a different runtime (e.g. the Go runtime), it knows nothing of /var/run/nscd/socket. This is your first reason for not using nscd.

Leave a Comment