Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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)
    #     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
    nameserver 4.2.2.4
    search asqar.net
    
  2. I'm using bind9 how can I set the DNS cache, any configure ?

share|improve this question
add comment

2 Answers

up vote 9 down vote accepted

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.

share|improve this answer
add comment

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 192.168.222.0/24 subnet.
The queries are forwarded to a dnscache namerver running on my OpenBSD firewall at 192.168.222.10.
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    {
    192.168.222.0/24  ;
};

options {
    forward only ;
    forwarders { 192.168.222.10 ; } ; 
    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

nameserver 192.168.222.25

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/

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.