If you want a DNS cache on your local machine, use dnsmasq, not BIND.
Unless you really need a local iterative nameserver, de-install BIND.
sudo apt-get purge bind9
Now for dnsmasq. There are two ways of using dnsmasq.
1: If you are using NetworkManager to manage networking then you already have the dnsmasq-base package installed; you just have to enable the NetworkManager-controlled dnsmasq instance by editing NetworkManager.conf
sudo gedit /etc/NetworkManager/NetworkManager.conf
and ensuring that the line
dns=dnsmasq
is present. Next enable caching in this dnsmasq instance. Create a new configuration file called, e.g., local
sudo gedit /etc/NetworkManager/dnsmasq.d/local
and add the single line
cache-size=150
to change the default cache size from zero. Then restart network-manager
sudo restart network-manager
which will also start or restart the NetworkManager-controlled dnsmasq instance using the new nonzero cache size.
This only works in Ubuntu 12.10 or later. In Ubuntu 12.04 the NetworkManager-controlled dnsmasq configuration cannot be customized and the cache size is zero.
2: The other way of using dnsmasq is to run it as a server. To do this, install the dnsmasq
package and configure it by editing /etc/dnsmasq.conf
and setting cache-size
to a value greater than zero.
In Ubuntu 12.10 the dnsmasq server will forward queries to external nameservers if the NetworkManager-controlled dnsmasq instance is disabled and will forward queries to the NetworkManager-controlled dnsmasq instance at the address 127.0.1.1 if the NetworkManager-controlled dnsmasq instance is enabled.
In Ubuntu 12.04 the same thing can be achieved but some additional manual configuration steps are required because in Ubuntu 12.04 the NetworkManager-controlled dnsmasq instance listens at 127.0.0.1 which conflicts with dnsmasq server in its default configuration.