How to Setup DNS server using Bind9 on Ubuntu 16.04

Join us at the Alibaba Cloud ACtivate Online Conference on March 5–6 to challenge assumptions, exchange ideas, and explore what is possible through digital transformation.

By Hitesh Jethva, Alibaba Cloud Tech Share Author. Tech Share is Alibaba Cloud’s incentive program to encourage the sharing of technical knowledge and best practices within the cloud community.

DNS (Domain Name System) is an internet service that can be used to translate the user-friendly domain into computer-friendly IP addresses. You can also perform reverse translation i.e. from IP addresses to domain name translations using DNS. BIND also known as a Berkeley Internet Name Domain is an open source implementation of DNS. BIND allows you to publish DNS information on the internet and resolve DNS queries for the users. BIND is one of the most widely used DNS software around the world. Putting a DNS server on a network is a great way to improve the management of your servers and desktop systems. You can configure different views in a single BIND server. This allows you to give internal and external users different views of your DNS data, keeping some DNS information private. BIND comes with wide range of features including, TSIG, nsupdate, IPv6, rndc, views, multiprocessor support, Response Rate Limiting (RRL), DNSSEC, Split DNS, DNSSEC Validation and much more.

In this tutorial, we will go through how to set up a Domain Name System (DNS) server using BIND9 on an Alibaba Cloud Elastic Compute Service (ECS) Ubuntu 16.04 server.

Prerequisites

  1. A fresh Alibaba Cloud Ubuntu 16.04 instance.
  2. A static IP address 192.168.0.102 setup in your instance.
  3. A root password is set up to your instance.

Launch Alibaba Cloud ECS Instance

First, log in to your Alibaba Cloud ECS Console. Create a new ECS instance, choosing Ubuntu 16.04 as the operating system with at least 2GB RAM. Connect to your ECS instance and log in as the root user.

Once you are logged into your Ubuntu 16.04 instance, run the following command to update your base system with the latest available packages.

Install BIND 9

By default, BIND 9 is available in the Ubuntu 16.04 default repository. You can easily install it by just running the following command:

After installing BIND 9, you will need to set BIND to IPv4 mode. You can do this by editing /etc/systemd/system/bind9.service file:

Make the following changes:

Save and close the file. Then, reload the systemd daemon to read the new configuration into the running system:

Next, restart BIND service to apply the changes:

Configure BIND 9

All the configuration files for BIND 9 are located inside /etc/bind directory. First, you will need to edit /etc/bind/named.conf.options file and add forwarders. Forwarders. DNS query will be forwarded to the forwarders when your local DNS server is unable to resolve the query.

Add the following lines:

Save and close the file. Then, you will need to configure /etc/bind/named.conf.local file. This file will be used to define the zone for your domain.

Add the following lines:

Save and close the file, when you are finished.

Configure Forward and Reverse Lookup Zone

Next, you will need to configure forward and reverse lookup zone for your domain. A forward lookup zone is a DNS zone in which hostname to IP address relations is stored. When a computer asks the IP address of a specific hostname, the forward lookup zone is checked and the desired result is returned.

A reverse lookup zone is the opposite of a forward lookup zone. It returns the fully qualified domain name of a host based on its IP address.

Here, we will use test.example.com as a private Fully-Qualified Domain Name.

First, change the directory to the /etc/bind with the following command:

Next, copy the sample forward and reverse lookup zone file with the following command:

Next, open the forward lookup zone file:

Make the following changes:

Save and close the file. Then, open reverse lookup zone file:

Make the following changes:

Save and close the file. Then, open /etc/resolv.conf file:

Add the following lines:

Save and close the file. Then, restart BIND 9 service to apply the changes:

Next, check the forward and reverse lookup zone file for any syntax error with the following command:

If everything is fine. You should see the following output:

Next, check the reverse lookup zone file:

If everything is fine. You should see the following output:

Test BIND 9 DNS Server

BIND 9 is now configured. It’s time to check whether it is working or not.

Here, we will use the dig command line tool to check DNS & its related information with the following command:

You should see the following output:

Now, test using the reverse lookup query as shown below:

Output:

You can also use nslookup command against your DNS server to confirm the output of dig command:

You should see the following output:

Next, use nslookup command against your DNS server IP address:

You should see the following output:

That’s it! You have successfully installed and configured BIND 9 on Alibaba Cloud Elastic Compute Service (ECS) Ubuntu 16.04 server.

Reference:https://www.alibabacloud.com/blog/how-to-setup-dns-server-using-bind9-on-ubuntu-16-04_594469?spm=a2c41.12583900.0.0

Follow me to keep abreast with the latest technology news, industry insights, and developer trends.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store