The DNSMasq tiny but powerful dhcp and dns server. I use it to provide local resolver functionality and rewriting some addresses for my everyday needs.
This is short note demonstrate easy and fast way to install and configure DNSMasq. More info about configuration options you can find in official documentations.
To install dnsmasq on CentOS6 you does not need to add any additional repos -- just install it!
yum install dnsmasq
Create base configuration file. Mine is:
cat << EOF > /etc/dnsmasq.conf resolv-file=/etc/resolv.dnsmasq.conf interface=lo,tun0 bind-interfaces cache-size=0 log-facility=/var/log/dnsmasq/lo/dnsmasq.log #log-queries # Uncomment this line to enabe queries logging #address=/google.com/127.0.0.1 # Address rewrite example #mx-host=mx.example.com,mx.mydomain.com,10 #server=/myzone/10.0.0.1 # Forward to anather DNS for zone 'myzone' EOF
Set dnsmasq as local resolver
cat << EOF > /etc/resolv.conf nameserver 127.0.0.1 EOF
Set few external DNS servers
cat << EOF > /etc/resolv.dnsmasq.conf nameserver 126.96.36.199 nameserver 188.8.131.52 EOF
service dnsmasq start chkconfig dnsmasq on
netstat -tnlp | grep dnsmasq tail -f /var/log/dnsmasq/lo/dnsmasq.log dig a google.com @localhost