Tag Archives: nscd

NSCD – Cache DNS requests

DNS queries can be an issue on Cloud infrastructure, where SaaS are generally configured using FQDN instead of IP. This means that every time your application needs MySQL or Redis or any of the Platform/Software as a service, a DNS query will be issued.

Sometimes this could hammer the local DNS and service providers might block your DNS traffic.

To minimise this, you could use nscd to cache the DNS queries and reduce the traffic to the local DNS servers.

>> Test if port 53 has been blocked
tcpdump -vvv -s 0 -l -n port 53

>> Check what is currently cached
nscd -g (and check hosts cache)

>> Configuration file
grep -v "^#" /etc/nscd.conf (leaving only 'hosts' details)

	server-user		nscd
	debug-level		0
	paranoia		no

	enable-cache		hosts		yes
	positive-time-to-live	hosts		3600
	negative-time-to-live	hosts		20
	suggested-size		hosts		211
	check-files		hosts		yes
	persistent		hosts		yes
	shared			hosts		yes
	max-db-size		hosts		33554432