A No Nonsense Blog

Actually Its full of Nonsense

dnsmasq – Browse the Web Faster

Heres how you can cache DNS to make browsing faster.
I am using Ubuntu and dnsmasq can be found in the repositories. (You’ll need to add Universe repository) You could also download dnsmasq here.

Do this if you’re using Ubuntu/Debian”

sudo apt-get install dnsmasq

now edit the file /etc/dnsmasq.conf and add the following

listen-address=127.0.0.1

Then edit /etc/dhcp3/dhclient.conf and find the line

prepend domain-name-servers 127.0.0.1;

and uncomment it (remove the “#” in front of it).

Now open /etc/resolv.conf , It should look something like this

nameserver 208.67.222.222
nameserver 208.67.220.220

and add “nameserver 127.0.0.1″ at the begining

nameserver 127.0.0.1
nameserver 208.67.222.222
nameserver 208.67.220.220

now lets restart dnsmasq:

sudo /etc/init.d/dnsmasq restart

now type this in terminal

dig google.com

Check the line that says “;; Query time: XX msec”

now try again and see that the query time is reduced to near 0 ms

Here is what I got

d1g1t@Kureyon:~$ dig d1g1t.net

;; ANSWER SECTION:
d1g1t.net. 3600 IN A 38.99.249.154

;; Query time: 562 msec

d1g1t@Kureyon:~$ dig d1g1t.net

;; Query time: 0 msec

The first one was using my actual DNS server, and the second one which used the dns cached by dnsmasq.


You may also change the TTL (Time-to-Live) in the /etc/dnsmasq.conf
this is the amount of time the DNS record is cachedsearch for “#local-ttl=” put the time in seconds and don’t forget to uncomment the line (i.e, remove the “#”)

Advertisement

4 Responses to dnsmasq – Browse the Web Faster

  1. Linux Blog July 14, 2009 at 6:10 pm

    This settings doesn’t came directly as default configuration? I didn’t use dnsmask until now, but I will give it a try!

    Regards

  2. QuarkBomb August 20, 2009 at 3:29 am

    local-ttl= has nothing to do with caching DNS queries, doyle.

  3. Richard Staib January 25, 2011 at 1:42 am

    the step to add 127.0.0.1 to the/etc/resolv.conf file in Ubuntu 10.10 does not work because NetworkManager overwrites the file every time it starts. To get around this ;
    1. Click on NetworkManager icon.
    2. Click on Edit Connection
    3. Select Connection
    4. Click Edit
    5. Find the DNS Server line.
    6. Add the 127.0.01 to the beginning of the line,
    separated by a semi-colon.

Leave a Reply

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.