Setup a DNS cache server using dnsmasq
Dnsmasq is a lightweight, easy to configure, DNS forwarder and DHCP server. It is designed to provide DNS and optionally, DHCP, to a small network. It can serve the names of local machines which are not in the global DNS.
apt-get update apt-get install dnsmasq
if installed successful, test it by:
dig google.com @localhost
Setup local caching
Edit /etc/dnsmasq.conf (default location in debian linux).
#listen-address=0.0.0.0 ## default port=53 no-poll no-resolv #forwarding google dns and opendns server=220.127.116.11 server=18.104.22.168 server=22.214.171.124 server=126.96.36.199 cache-size=1024 neg-ttl=7200 max-ttl=86400 interface=eth0 interface=lo0
In order to configure dnsmasq to act as cache for the host on which it is running, put
nameserver 127.0.0.1 in /etc/resolv.conf to force local processes to send queries to dnsmasq.
then restart dnsmasq.