How to increase DNS queries performance with DNSMasq

I decide to try to improve DNS queries performance (and traffic) on our SQUID proxy server using dnsmasq as cache. All DNS queries should go to dnsmasq, while dnsmasq forward the queries to upstream DNS servers.

First install DNSMASQ:

apt-get update
apt-get install dnsmasq

Edit /etc/dnsmasq.conf adding your preferred DNS and the interface:



“bogus-priv” tells dnsmasq never forward reverse-lookup queries which have local subnet ip rage to upstream. Which means ‘nslookup’ will not be forwarded to upstream instead dnsmasq will try to resolv itself. If it doesn’t find hostname for in /etc/hosts then it will send back ‘no such domain’ response.

On /etc/resolv.conf whatever you put on /etc/network/interfaces you will find your loop-back interface as DNS. This because resolvconf put when dnsmasq start.
Tu append some other nameserver entries on resolv.conf after edit the file /etc/resolvconf/resolv.conf.d/tail:


and then run

resolvconf -u

to update the configuration.
If you whant to append nameserver entrie before, use instead this file:

For testing purposes, run can run dnsmasq with this options:

dnsmasq --no-daemon --log-queries



Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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