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 server=22.214.171.124 server=126.96.36.199 listen-address=127.0.0.1
“bogus-priv” tells dnsmasq never forward reverse-lookup queries which have local subnet ip rage to upstream. Which means ‘nslookup 192.168.0.1’ will not be forwarded to upstream instead dnsmasq will try to resolv itself. If it doesn’t find hostname for 192.168.0.1 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 127.0.0.1 when dnsmasq start.
Tu append some other nameserver entries on resolv.conf after 127.0.0.1 edit the file /etc/resolvconf/resolv.conf.d/tail:
and then run
to update the configuration.
If you whant to append nameserver entrie before 188.8.131.52, use instead this file:
For testing purposes, run can run dnsmasq with this options:
dnsmasq --no-daemon --log-queries