Best Way to Set Up DNS Caching

cachednsperformancePROXY

In order to speed up DNS lookups, I want to install a DNS cache or proxy.

I can see at least three programs I think will do the job: bind9, pdnsd, or dnsmasq.

I would like to make sure that if I install one of I do not leave it poorly configured from a performance or security point of view. So, what would people recommend, and are there any configuration changes I should immediately make after installing?

Best Answer

  1. Install bind9
  2. Point resolv.conf to 127.0.0.1

To do this follow this steps:

To Install Bind9

  1. Open "Ubuntu Software Center" (Applications->Ubuntu Software Center)
  2. Search for bind9
  3. Check to display "Technical Items"
  4. Mark bind9 and install it

Update /etc/resolv.conf

  1. Open Network Manager (System->Preferences->Network Manager)
  2. Find your connection and edit it (wired or wireless)
  3. Toggle "IPV4 configuration" tab
  4. On "DNS Servers" field write 127.0.0.1

It's done!

To test

Open gnome-terminal (Applications > Accessories > Terminal ) and type

dig ubuntu.com 

(if you don't have it, install dnsutils package as explained to bind9)

Check the last answers, as an example:

My first query at ubuntu.com

;; Query time: **209 msec**
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Sat Jan 22 12:20:12 2011
;; MSG SIZE  rcvd: 196

My second query:

;; Query time: **0 msec**
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Sat Jan 22 12:18:23 2011
;; MSG SIZE  rcvd: 156

The server 127.0.0.1 means that you're resolving locally. Take a look in query time (surrounded by **) , the second one is cached.

Related Question