In this tutorial, I show you how to Install and Configure DNS servers on a Linux system. If you want to understand how DNS works please click this URL how DNS works?
Before, Install and configure the DNS system you need to understand and know about your DNS structure.
BIND is the best software for handling DNS service. BIND stands for Berkley Internet Naming Daemon developed by ISC (Internet Systems Consortium). Learn more about ISC by https://www.isc.org/.
Installation BIND9
To install the bind9 package using the appropriate package management utilities for your Linux distro.
On Debian/Ubuntu flavors, do the following:
$ sudo apt-get update
$ sudo apt-get install bind9 bindutils -y
1. Configure Cache NameServer
For configuring cache server we need to modify a file named.conf.options in /etc/bind/named.conf.options and uncomment and edit of forwarders and add IP address to your ISP (Internet Service Provider) or you can use any Open DNS or public DNS like Google's DNS (8.8.8.8, 8.8.4.4)
forwarders {
8.8.8.8;
8.8.4.4;
};
2. Configure Primary/Master Nameserver
Primary/Master Server stores all recordsudo vi /etc/bind/named.conf
Make sure that it contains the following lines and NOT commented:
include “/etc/bind/named.conf.options”;
include “/etc/bind/named.conf.local”;
include “/etc/bind/named.conf.default-zones”;
To add a DNS Forward and Reverse resolution to bind9, edit /etc/bind9/named.conf.localsudo vi /etc/bind/named.conf.local
sudo cp /etc/bind/db.local /etc/bind/db.myserver-lab.com
Edit file to your domain. It easy to remember to use.sudo vi /etc/bind/db.myserver-lab.com
Look like this:sudo systemctl restart bind9
After you create the reverse zone, Now let's edit a file that copies from the template. Just like command bellow:
forwarders {
8.8.8.8;
8.8.4.4;
};
2. Configure Primary/Master Nameserver
Primary/Master Server stores all record
sudo vi /etc/bind/named.conf
Make sure that it contains the following lines and NOT commented:
include “/etc/bind/named.conf.options”;
include “/etc/bind/named.conf.local”;
include “/etc/bind/named.conf.default-zones”;
sudo vi /etc/bind/named.conf.local
sudo cp /etc/bind/db.local /etc/bind/db.myserver-lab.com
Edit file to your domain. It easy to remember to use.sudo vi /etc/bind/db.myserver-lab.com
Look like this:sudo systemctl restart bind9
sudo cp /etc/bind/db.127 /etc/bind/db.10
10 is my start IP address number from my DNS serversudo systemctl restart bind9
Finally, we have installed and configured the DNS server on Ubuntu successfully. Any questions just leave a comment and we will be glad to help you.