DNS is the system which is used to convert human-readable hostnames (such as example.com) into the IP addresses that are actually used to contact the services running upon them.

Caching DNS

If you're running applications that require the lookup of a large number of IP addresses the single best thing you can do is deploy a local DNS-cache.

Many services perform DNS lookups, including webservers and log-analyzing software, and mail-servers.

NOTE: Mail-servers might perform significantly more DNS lookups than you expect if you're using a DNS-based blacklist for rejecting SPAM at submission-time.

One of the simplest DNS dedicated DNS-caches is pdnsd, this works in two ways:

Installing pdnsd on Debian Systems

Installation is pretty simple, using the standard aptitude command:

# aptitude install pdnsd

Once installed you need to change the "START_DAEMON=" setting to be "yes" in /etc/default/pdnsd, at which point you can start the deamon:

# /etc/init.d/pdnsd start

Assuming that works you can test the software by performing a lookup, and timing it:

$ dig -t a example.com @ | grep time
;; Query time: 29 msec

Repeating that lookup should show the second attempt took zero seconds:

$ dig -t a example.com @ | grep time
;; Query time: 0 msec

If that second query was indeed "instant" then you can switch to using your caching DNS server by updating /etc/resolv.conf to refer to it: