Enabling DNS cache with dnsmasq on Gentoo

I've just found a nice article about enabling DNS-Cache for Konqueror at fedorawiki.de. It's very useful, because Konqueror doesn't provide this feature. If you take e.g. the german freemail provider http://gmx.net, Konqueror sends a huge amount of dns queries to load all the pictures and stuff. You really notice the performance gain if you cache these queries with a local DNS server, for example dnsmasq.

Here are the steps to install and configure dnsmasq:

Install dnsmasq
# emerge -av dnsmasq

Then insert 'nameserver' into the first (important!) line in /etc/resolv.conf


Then start dnsmasq
# /etc/init.d/dnsmasq start

You can test your local DNS cache by typing
dig google.de

Have a look at the query time (must be something higher than 50ms in most cases). Query google again.
Now that's amazing, isn't it? 0msec!

Let dnsmasq start at boot (otherwise you can't resolve any DNS names because you've edited the /etc/resolv.conf)
# rc-update add dnsmasq default

Further reading