How to build a local DNS caching server

Being in Malaysia we are gifted with superior Internet speeds. NOT!!

Services like openDNS are awesome but the lag between us and them often results in sluggish performance anyways.

One way to improve performance is to use local DNS servers. I don’t use Streamyx’s DNS servers because they SUCK!!. TIME’s DNS servers are ok but I still prefer openDNS.

To improve performance, I put together a local DNS caching-only server that forwards to openDNS. Now I have openDNS with lighting fast response.

Let’s walk though the steps to get your own local DNS caching-only server setup. I’m using openSUSE 11 so the steps might vary depending on your distro.

1. Install BIND

pandora:~ # zypper in bind

2. Edit /etc/named.conf

pandora:~ # vi /etc/named..conf

Uncomment the forwarders section. Update the default values with the values below.

forwarders { 208.67.222.222; 208.67.220.220; };

forward only;

Add the line ” forward only; ” This will tell BIND to only forward to the forwarders and not the ROOT servers.

3. Start the service.

To have the service start automatically run ” chkconfig named on

pandora:~ # service named start

4. Let’s make sure your caching server is running fine.

pandora:~ # nslookup google.com localhost
Server:         localhost
Address:        127.0.0.1#53

Non-authoritative answer:
Name:   google.com
Address: 64.233.167.99
Name:   google.com
Address: 72.14.207.99
Name:   google.com
Address: 64.233.187.99


pandora:~ # nslookup yahoo.com localhost
Server:         localhost
Address:        127.0.0.1#53

Non-authoritative answer:
Name:   yahoo.com
Address: 68.180.206.184
Name:   yahoo.com
Address: 206.190.60.37

5. Update your /etc/resolv.conf file.

This will tell your system to use the local DNS server which we just setup instead of the external ones.

Add the lines below to the file.

nameserver 127.0.0.1
nameserver 127.0.0.2

That’s it. You now have local DNS caching. Enjoy!!

My /etc/named.conf file. Only the lines I changed.

#forwarders { 192.0.2.1; 192.0.2.2; };
forwarders { 208.67.222.222; 208.67.220.220; };

# Enable the next entry to prefer usage of the name server declared in
# the forwarders section.

#forward first;
forward only;

2 Responses to “How to build a local DNS caching server”

Author comments are in a darker gray color for you to easily identify the posts author in the comments

  1. hiu says:

    One question: How do you make your zyper working?

  2. Danesh says:

    Hiu,

    zypper should be there by default. It should be ran as root.

Leave a Reply

© 2008-2009 The Danesh Project
Powered by Wordpress and made by Guerrilla. Best viewed in Mozilla Firefox