I want to have strong DNS cache server on my local host (server). So I need to change name server to my localhost.

  1. How can I change it? byt this config it seems I must don't change it via editor so how can I change it?

    root@asqar# cat /etc/resolv.conf 
    # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
    search asqar.net
  2. I'm using bind9 how can I set the DNS cache, any configure ?

2 Answers 2


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


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


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 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 which conflicts with dnsmasq server in its default configuration.


this may be helpful, I don't think it will work as is on ubuntu but you should be able to adapt it easily.

A simple named.conf which forwards all DNS queries to another nameserver, and caches the answers for possible reuse. Tested under OpenBSD 4.7 BETA with

$ named -v
BIND 9.4.2-P2

This type of configuration is useful to minimize the repeating nameserver queries issued when surfing the web. Not only for your notebook or laptop using wireless connections, but also for a department that wishes to make use of a LAN/WAN link efficiently.

The Access Control List (acl) limits useage of this forward-only nameserver to my local subnet.
The queries are forwarded to a dnscache namerver running on my OpenBSD firewall at
The cache size is limited to two MB, which probably is too much for a notebook or laptop. The comments show how to calculate this

amount in bytes using bc(1), the unlimited precision calculator.

// Caching and forward only configuration

// Access Control List

acl  clients    {  ;

options {
    forward only ;
    forwarders { ; } ; 
    allow-query { clients ; } ;
    // max-cache-size is in bytes : echo '2 * 1024^2' | bc
    max-cache-size 2097152 ; 
    empty-zones-enable yes;
} ;

# After editing this file please use 'named-checkconf' to validate!

To enable this under OpenBSD, assuming the above configuration has been saved as /var/naned/etc/caching-forward-only.conf, you have to add the following to /etc/rc.conf.local:

named_flags='-4 -c /etc/caching-forward-only.conf'

Note that applications use the /etc/resolv.conf to find out which name server they should use. So for a departmental nameserver, all clients should have the iP address of that name server in /etc/resolv.conf

For my small department in the garage, the clients have the following in /etc/resolv.conf


reference : http://www.daemonforums.org/showthread.php?t=4471

or try this, seems more Ubuntu-centered : http://soledadpenades.com/articles/ubuntu/using-bind-as-a-local-caching-name-server/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .