Dns Cache with dnsmasq

To make a faster browsing , you can use dns cache.

To understand why you should use dns cache, you should learn how dns works.

With the each client request, dns try to find ip address for domain. Forexample for each you type www.google.com, your browser try to find google.com ips again. Dns cache is hold this ip in local, so you can access faster.

I’m using dnsmasq , to install in ubuntu.

“sudo apt-get install dnsmasq”

to configure (i’m using static ip, if you are using a dynamic ip more configuration might have to be done. )

open /etc/dhcp3/dhclient.conf

“vi /etc/dhcp3/dhclient.conf”

change

#prepend domain-name-servers 127.0.0.1;

with

prepend domain-name-servers 127.0.0.1;

Example:

dig ebay.com

; <<>> DiG 9.5.1-P2 <<>> ebay.com
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 45431
;; flags: qr rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;ebay.com.            IN    A

;; ANSWER SECTION:
ebay.com.        2330    IN    A    66.211.160.88
ebay.com.        2330    IN    A    66.135.205.13
ebay.com.        2330    IN    A    66.135.205.14
ebay.com.        2330    IN    A    66.135.221.10
ebay.com.        2330    IN    A    66.135.221.11
ebay.com.        2330    IN    A    66.211.160.87


;; Query time: 140 msec

;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Sat Sep  5 23:21:51 2009
;; MSG SIZE  rcvd: 122

After dns cache:

dig ebay.com

; <<>> DiG 9.5.1-P2 <<>> ebay.com
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 17990
;; flags: qr rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;ebay.com.            IN    A

;; ANSWER SECTION:
ebay.com.        2327    IN    A    66.211.160.87
ebay.com.        2327    IN    A    66.135.221.11
ebay.com.        2327    IN    A    66.135.221.10
ebay.com.        2327    IN    A    66.135.205.14
ebay.com.        2327    IN    A    66.135.205.13
ebay.com.        2327    IN    A    66.211.160.88

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Sat Sep  5 23:21:54 2009
;; MSG SIZE  rcvd: 122


Related posts

Tags: , ,