Category: DNS server

DNS server

perl script to check Bind dns zone files

perl script to check Bind dns zone files

Introduction – is perl script used to check dns zone file syntax! This script verifies both Forward and Reverse Zone.
Internally perl script is using named-checkzone and named-checkconf. Bind dns commands to check zone file syntax.
Script is reading named.conf file to get all zone

* Download – Please download perl script from following locations…

* How to run/use –

root@localhost~# perl ./

* Usage: ./ { –verify }

root@localhost~# perl ./ –verify

zone myzone_internal.file/IN: loaded serial 2007013101

zone myzone_external.file/IN: loaded serial 2012100527

Thank you,
Arun Bagul

How to configure Local DNS caching!

How to configure Local DNS caching!

Introductions –

DNS server resolves domain names into IP addresses. So when you request “” for example, the DNS server finds out the address for the domain, and sends your request the right way.

You can run a DNS cache on your system This will speed up the process of looking up domain names while browsing. The difference is about 35-55ms. dnsmasq is the tool, we will be using for caching nameserver lookups

** How to install dnsmasq –

root@arunbagul:~# apt-get   install  dnsmasq
Reading package lists… Done
Building dependency tree


** How to configure dnsmasq –

The configuration file for dnsmasq is /etc/dnsmasq.conf. you can specify customized setting in this file…

root@arunbagul:~# vi /etc/dnsmasq.conf

Now uncomment the following line in /etc/dnsmasq.conf file. So that dnsmasq will listen on local loop ie address.


Now edit /etc/dhcp3/dhclient.conf and make sure that it looks  as shown below…

root@arunbagul:~# cat /etc/dhcp3/dhclient.conf

prepend domain-name-servers;
request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, host-name,
netbios-name-servers, netbios-scope;


How it dnsmasq works? –

If you are using DHCP connection ,then whenever you get a new dhcp lease, the dhcp3 client will updates the /etc/resolv.conf file on your system with the right values for the DNS servers to use. Adding the “prepend” option as we did above ensures that “nameserver” will appear on the top of the list of DNS servers. So in the future, whenever your system want to resolve a domain name, it will forward that request to local dnsmasq. dnsmasq maintains it’s own cache. If the details for the domain name are already in you cache, well and good, dnsmasq will serve it up and make the process real fast. If it is not in the cache, then dnsmasq will look at the /etc/resolv.conf file and use the nameservers listed below the line “nameserver″…

Check your /etc/resolv.conf file –

root@arunbagul:~# cat /etc/resolv.conf

where is “nameserver” entry? This is because. Since dhcp haven’t renewed your lease after editing the /etc/dhcp3/dhclient.conf file. Let us add that in manually. see below

root@arunbagul:~# cat /etc/resolv.conf

** Now is to start dnsmasq so that the changes we made to the configuration file take effect-

root@arunbagul:~# /etc/init.d/dnsmasq
Usage: /etc/init.d/dnsmasq {start|stop|restart|force-reload}

root@arunbagul:~# /etc/init.d/dnsmasq start
Starting DNS forwarder and DHCP server: dnsmasq.

Yes!! we are running our local DNS cache. If you want to measure your speed improvement then dig to some domain and find out how fast is Local DNS cache!

root@arunbagul:~# dig

command(1) dnsmasq – is a lightweight DHCP and caching DNS server. Dnsmasq accepts DNS queries and either answers them from a small, local, cache or forwards them to a real, recursive, DNS server. It loads the contents of /etc/hosts so that local hostnames which do not appear in the global DNS can be resolved and also answers DNS queries for DHCP configured hosts. The dnsmasq DHCP server supports static address assignments, multiple networks & DHCP-relay.


-h, –no-hosts
Don’t read the hostnames in /etc/hosts.

-H, –addn-hosts=<file>
Additional hosts file. Read the specified file as well as /etc/hosts.

-E, –expand-hosts
Add the domain to simple names (without a period) in /etc/hosts in the same way as for DHCP-derived names.

-T, –local-ttl=<time>
When replying with information from /etc/hosts or the DHCP leases file dnsmasq by default sets the time-to-live field to zero, meaning that
the requestor should not itself cache the information. This is the correct thing to do in almost all situations.

-k, –keep-in-foreground
Do not go into the background at startup but otherwise run as normal. This is intended for use when dnsmasq is run under daemontools or

-d, –no-daemon
Debug mode: don’t fork to the background, don’t write a pid file, don’t change user id, generate a complete cache dump on receipt on
SIGUSR1, log to stderr as well as syslog, don’t fork new processes to handle TCP queries.

-q, –log-queries
Log the results of DNS queries handled by dnsmasq. Enable a full cache dump on receipt of SIGUSR1.

-x, –pid-file=<path>
Specify an alternate path for dnsmasq to record its process-id in. Normally /var/run/

-u, –user=<username>
Specify the userid to which dnsmasq will change after startup. Dnsmasq must normally be started as root, but it will drop root privileges
after startup by changing id to another user. Normally this user is “nobody” but that can be over-ridden with this switch.

-g, –group=<groupname>
Specify the group which dnsmasq will run as. The defaults to “dip”, if available, to facilitate access to /etc/ppp/resolv.conf which is not
normally world readable.

-v, –version
Print the version number.

-p, –port=<port>
Listen on <port> instead of the standard DNS port (53). Useful mainly for debugging.

Arun Bagul