Beginner’s guide to implementing DNS server using BIND
Last updated on March 12th, 2018 at 08:53 pm
As we know that every machine on a network has a IP address assigned to it, which is like a unique address of that machine in our network. In similar way, every website on internet has a IP address associated to it but we normally don’t use those IP addresses to access the website rather we use a name like google.com or facebook.com. Just imagine how hard would it be to remember IP addresses of all these website, if these names for not in use. So, how does these name translate into IP addresses, that’s because of DNS servers.
DNS (short for Domain Name System) is a service which translates IP address into domain name & vice-versa. In environment with only a limited numbers of Linux machines, we can make entries in /etc/hosts file for associating an IP address with a name but when you have a large infrastructure with lots and lots of systems/resources, /etc/hosts will not work. For these kind of scenarios, we implement BIND (DNS) in our environment.
BIND or Berkeley Internet Name Domain, is most widely used Open source software that implements DNS protocols for internet, which provides us ability to implement IP to domain name conversion & vice-versa .
In this tutorial, we will learn to implement BIND (DNS) server in our local environment. But before we do that there are some DNS records that we need to be aware of. Although there are a number of DNS records but we will only discuss some of the important ones which will be used in this tutorial.
A record is used to map hostname to an IPaddress
NS (Name server) record identifies authoritative DNS server for the zone
MX (mail exchanger) record specifies a mail server responsible for accepting of mail in the zone
CN (canonical name) record specifies alias of one name to another name,
PTR (Pointer) record are reverse DNS record i.e. from IP address to hostname
SOA (Start of Authority) record contains information about that DNS zones & other DNS records.
Now, let’s start with installation & configuration of DNS/BIND
In our scenario, we need a DNS server machine & a client machine for testing
DNS server Name dns.ltechlab.com Client name client1.ltechlab.com
IP address 192.168.1.100 IP address 192.168.1.101
Firstly, we will install BIND package with the following command
After these packages have been installed, we will move onto configuration part.
Note:- Before we move to configuration, make sure that you are able to ping your server by hostname. If not, open your /etc/hosts file & make following entry
Main configuration file BIND is /etc/named.conf & this is where we will be making most of the configurations. Now, open the configuration file & comment the following lines,
This is will let our DNS server to listen to all IPs, next we will add our network to the file so that clients from our network can query DNS
next if you are using a slave server also, mention that also (optional) (will discuss master-slave setup in future tutorial)
Now, we will be creating our zone files.
Creating Zones entries
Firstly we will create a forward zone entry in /etc/named.conf for our domain ltechlab.com. Add the following lines in named.conf
Here, ‘ltechlab.com’ is the Domain name,
‘master’ is the Primary DNS,
fwd.ltechlab.com.db is the Forward lookup file,
‘allow-update’ will be none, its the primary DNS.
Similarly, we will now create an entry for reverse zone as well in”named.conf”
1.168.192.in-addr.arpa is Reverse lookup name,
master is for Primary DNS,
1.168.192.db is the reverse lookup file,
allow-update – will be set to none, since this is the primary DNS.
Our configuration for “named.conf” is complete & next we will create zone files for our BIND server.
Creating zone files
We will first create our forward zone file i.e “fwd.ltechlab.com.db” in “/var/named” folder and then will make the following entries in it
Similarly, we will create reverse zone file named “1.168.192.db” in “/var/named” folder with the following content
After creating these zone files, we will restart our BIND server
Now, we will verify our zone files.
Verifying the zones
Login to your client machine i.e. client1.ltechlab.com & open “/etc/resolve.conf” and enter following entry
Or change the DNS entry in /etc/sysconfig/network-scripts/ifcfg-e….
and restart your network services
Now that we have made the changes on our client machine, we will make sure that our DNS serevr is working fine by running “dig ” command against our web server name i.e. www.ltechlab.com (dig command is a tool for querying DNS servers)
We have received an output to our query successfully. Now, let’s check if our reverse zone is working fine or not
NOTE :- If you receive an error while running “DIG” command on client machine, install “bind-utils” package on the machine.
That’s it guys, we have successfully created our DNS server using BIND & will also post a tutorial soon with Master-slave setup. If you have any queries/comments, please mention them in the comment box down below.