gnotaras
3rd October 2010, 08:51 AM
The following mini-HOWTO is taken from a guide about how to configure dnsmasq as a caching nameserver (http://www.g-loaded.eu/2010/09/18/caching-nameserver-using-dnsmasq/), written by George Notaras and published under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 License (http://creativecommons.org/licenses/by-nc-sa/3.0/).
What is a caching nameserver?
A caching nameserver is a DNS service that keeps a local cache of domain name to IP address mappings. Once the DNS information is cached, it is no longer needed to forward the queries to the upstream nameservers. This results in faster domain name resolution. This means that several tasks like web browsing or email processing by spam filters may get a little performance boost.
Both desktops and servers may benefit from using a local caching nameserver.
Why dnsmasq?
It is mature, lightweight and does the job efficiently.
Installation
Install using yum:
yum install dnsmasq
Configuration
Save the following configuration file in /etc/dnsmasq.conf
#
# Configuration file for dnsmasq acting as a caching nameserver.
#
# Format is one option per line, legal options are the same
# as the long options legal on the command line. See
# "/usr/sbin/dnsmasq --help" or "man 8 dnsmasq" for details.
#
# Updated versions of this configuration file may be available at:
#
# http://www.g-loaded.eu/2010/09/18/caching-nameserver-using-dnsmasq/
#
#
# Basic server configuration
#
listen-address=127.0.0.1
port=53
bind-interfaces
user=dnsmasq
group=dnsmasq
pid-file=/var/run/dnsmasq.pid
#
# Logging
#
#log-facility=/var/log/dnsmasq.log
#log-queries
#
# Name resolution options
#
domain-needed
bogus-priv
no-hosts
dns-forward-max=150
cache-size=1000
#no-negcache
neg-ttl=3600
resolv-file=/etc/resolv.dnsmasq
no-poll
Save the list of the upstream nameservers in the file: /etc/resolv.dnsmasq
The following IPs are used as an example. Use the IP addresses of your ISP's DNS servers.
nameserver 192.168.0.252
nameserver 192.168.0.253
nameserver 192.168.0.254
Start the dnsmasq service:
/etc/init.d/dnsmasq start
Make the system use the dnsmasq service for domain name resolution:
echo "nameserver 127.0.0.1" > /etc/resolv.conf
Enjoy!
For more details about the used directives plus some tips about logging to file, please read the full dnsmasq guide (http://www.g-loaded.eu/2010/09/18/caching-nameserver-using-dnsmasq/).
What is a caching nameserver?
A caching nameserver is a DNS service that keeps a local cache of domain name to IP address mappings. Once the DNS information is cached, it is no longer needed to forward the queries to the upstream nameservers. This results in faster domain name resolution. This means that several tasks like web browsing or email processing by spam filters may get a little performance boost.
Both desktops and servers may benefit from using a local caching nameserver.
Why dnsmasq?
It is mature, lightweight and does the job efficiently.
Installation
Install using yum:
yum install dnsmasq
Configuration
Save the following configuration file in /etc/dnsmasq.conf
#
# Configuration file for dnsmasq acting as a caching nameserver.
#
# Format is one option per line, legal options are the same
# as the long options legal on the command line. See
# "/usr/sbin/dnsmasq --help" or "man 8 dnsmasq" for details.
#
# Updated versions of this configuration file may be available at:
#
# http://www.g-loaded.eu/2010/09/18/caching-nameserver-using-dnsmasq/
#
#
# Basic server configuration
#
listen-address=127.0.0.1
port=53
bind-interfaces
user=dnsmasq
group=dnsmasq
pid-file=/var/run/dnsmasq.pid
#
# Logging
#
#log-facility=/var/log/dnsmasq.log
#log-queries
#
# Name resolution options
#
domain-needed
bogus-priv
no-hosts
dns-forward-max=150
cache-size=1000
#no-negcache
neg-ttl=3600
resolv-file=/etc/resolv.dnsmasq
no-poll
Save the list of the upstream nameservers in the file: /etc/resolv.dnsmasq
The following IPs are used as an example. Use the IP addresses of your ISP's DNS servers.
nameserver 192.168.0.252
nameserver 192.168.0.253
nameserver 192.168.0.254
Start the dnsmasq service:
/etc/init.d/dnsmasq start
Make the system use the dnsmasq service for domain name resolution:
echo "nameserver 127.0.0.1" > /etc/resolv.conf
Enjoy!
For more details about the used directives plus some tips about logging to file, please read the full dnsmasq guide (http://www.g-loaded.eu/2010/09/18/caching-nameserver-using-dnsmasq/).