Tip: using dnsmasq

Thilo Six T.Six at gmx.de
Mon Mar 20 18:47:08 UTC 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160


Hello

I have found a good way to increase the online speed by accident.
Probably some of you already know it, but others like me do not.
dnsmasq is a small Nameserver (with DHCP functionality which is not used
here).

How does it improve online speed?
Well it works as a local DNS cache. Therefor not every DNS lookup that
is needed during surfing, or anywere else in your machine is needed to
be send out to upstream DNS.
Have a look here:

WITHOUT dnsmasq:
$ dig google.com

<snip>

;; Query time: 21 msec
              ^^^^



WITH dnsmasq:
$ dig google.com

<snip>

;; Query time: 1 msec
              ^^^


That doesn?t sound much. 20msec
But this is only one request, during surfing you do a lot of this.

The advantages are:
	- faster name resolution
	- less stress on upstream DNS

Here I received a reasonable speed advantage with dnsmasq during surfing.

What needs to be done, if your interrested?

1. install it
$ sudo aptitude install dnsmasq

2. make a copy of your current resolv.conf, which is later used by
   dnsmasq for upstream DNS requests
$ sudo cp /etc/resolv.conf /etc/dnsmasq.resolv.conf

3. change dnsmasq?s config
$ sudo nano -w /etc/dnsmasq.conf

(of course you can use the editor of your choice here)  ;)

in /etc/dnsmasq.conf i have changed this:

# Change this line if you want dns to get its upstream servers from
# somewhere other that /etc/resolv.conf
resolv-file=/etc/dnsmasq.resolv.conf

# If you want dnsmasq to listen for requests only on specified interfaces
# (and the loopback) give the name of the interface (eg eth0) here.
# Repeat the line for more than one interface.
#interface=lo
# Or you can specify which interface _not_ to listen on
#except-interface=
# Or which to listen on by address (remember to include 127.0.0.1 if
# you use this.)
listen-address=127.0.0.1
^^^^^^^^^^^^^^^^^^^^^^^^
This will bind [hehe bind not bind] dnsmasq to only local requests.
This is for the security of your system.


# Set the cachesize here.
cache-size=240

Default here is 150 but i have enough memory.


OK that?s the config for dnsmasq. Easy isn?t it?  ;)


4. restart dnsmasq to take into account the new config
$ sudo /etc/init.d/dnsmasq restart

5. make sure all DNS request go through dnsmasq
$ sudo nano -w /etc/resolv.conf

it should only contain this line:
nameserver 127.0.0.1

You probably could leave other nameservers below this line, but i am not
sure if they are used serial for top to bottom or randomly.

6. make sure our modified /etc/resolv.conf does not get changed by other
   programms
at this point YYMV. I have ADSL with pppoe here. If you use DHCP or ippp
you should check to prevent them to change /etc/resolv.conf.
With pppoe it is in:

$ sudo nano -w /etc/ppp/peers/dsl-provider
change the line:
usepeerdns
to
#usepeerdns


OK that?s it. :D
The changes take into account immediately.

Have fun

Thilo

- --
i am on Ubuntu 2.6 KDE
- - some friend of mine
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFEHviqzeyTbiZA74IRA/I/AJ0QakdKXTVIbiVJtHrPZQzdyrMjIACfXqgn
+xrNHc73hU0OD8qjHoN9o5E=
=eUaF
-----END PGP SIGNATURE-----





More information about the ubuntu-users mailing list