When it comes to installing DNS server on your linux environment, the most popular and recommended DNS server is BIND DNS server. It does a pretty decent job and statistically speaking, it is installed on quite a majority of systems around the world. The most used may not always be the best in every situation. BIND has a huge variety of customizing options but you may not always need it. We have already looked at how to point your domain to your VPS using BIND and now we will look at an alternative to BIND DNS server.
Another thing I learnt through my experience is that BIND DNS server takes approximately 100 MB of your RAM. If you are running a low end VPS, then it is definitely going to hamper performance in peak traffic time. Using a low end VPS also implies that you may not be doing great tasks on it. In this case you can settle for a simpler options.
NSD is one such name server I came across recently which was quick and easy to install. You can install it and deploy within 15 minutes and it works great. Great thing about NSD is it takes much lesser RAM as compared to BIND.
NSD uses zone files which are exactly similar to BIND. In certain cases you can even use the same zone files from BIND and make your NSD server work. NSD compiles the zone files via "zonec" and creates binary database files with .db extension. This enables fast start up of NSD daemon.
At the time of compiling these zone files, compiler outputs errors which might be causing errors. NSD compiler does not allow the errors to be forwarded to NSD daemon but output them on the console for the user to fix them.
Let us go through the installation steps and get NSD running immediately:
I will be installing NSD on CentOS 6.5. You can install it on any other linux distribution using equivalent commands, the steps remain the same.
yum install nsd
After installation, we need to configure the files. All the configuration files are stored in /etc/nsd/ folder in CentOS, whereas they are stored in /etc/nsd3/ in Ubuntu an Debian.
Open the configuration file to add in zone files required to be included at the time of execution.
All you have to do is add a couple of lines at the end of the file.
Now that you have included reference to the .db files, you need to create those files which would contain all the zone information. Do not worry, it is pretty simple!
Here is an example template for the zone file.
@ SOA ns1 firstname.lastname@example.org (
MX 10 mail.your-domain.com.
awstats.your-domain.com 86400 IN A 220.127.116.11
mail IN A 18.104.22.168
www IN A 22.214.171.124
ns1 IN A 126.96.36.199
ns2 IN A 188.8.131.52
* IN A 184.108.40.206
@ IN A 220.127.116.11
Once you have created your zone files, you must compile them using a command and see if it outputs any error,
You should get no errors.
Now you are done installing NSD DNS server!
service nsd restart
chkconfig nsd on
This will start NSD daemon and make sure it starts at time of boot.