0% found this document useful (0 votes)
18 views10 pages

DNS Lab

Uploaded by

nadim.nagati
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views10 pages

DNS Lab

Uploaded by

nadim.nagati
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Ubuntu

configure DNS Service


Hajer Boujezza
Networks and systems administration
2023/2024
(BIND DNS )
Table of contents
1. Introduction ........................................................................................................................................... 2
2. Service installation ................................................................................................................................ 2
3. Configure the Bind DNS Server ........................................................................................................... 3
4. Configure Bind DNS zone lookup files ................................................................................................ 5
• Create the forward zone lookup file .......................................................................................... 5
• Create the reverse zone lookup file ........................................................................................... 6
5. Check BIND DNS syntax ..................................................................................................................... 7
6. Updating Bind DNS Records ................................................................................................................ 8
7. Testing the DNS Server ........................................................................................................................ 8
8. Integration Part ..................................................................................................................................... 9
9. Conclusion ........................................................................................................................................... 10
10. References ........................................................................................................................................ 10
1. Introduction
The DNS service is a TCP/IP service that enables the matching between domain names and IP
addresses.

Goals:
• Configure local resolver
• Configure an IPV4 DNS server.
• Integration part between DNS and WEB server.
Before we begin installation of the necessary packages, we run the updated Ubuntu server:
sudo -s
# apt update -y

We can also use:


sudo apt update –fix-missing && apt upgrade -y

// upgrade runs if update is successful

2. Service installation
Download the necessary packages from Ubuntu base:

Next, we're going to install three packages on our DNS server:

• bind9 - The BIND 9 DNS server software.


• bind9utils - Utilities that make working with BIND 9 easier.
• bind9-doc - A documentation package for BIND 9.

#apt install -y bind9 bind9utils bind9-doc dnsutils

After installation, the BIND 9 service should be running. We check the status with this
command:

systemctl status bind9


3. Configure the Bind DNS Server

The named.conf file is BIND 9's main configuration file. That main file includes a reference to
/etc/bind/named.conf.options where we can specify options we need for our configuration. We'll
make four modifications to the /etc/bind/named.conf.options file:

• An acl directive that defines our local area network (LAN).


• An allow-query directive that defines what IP addresses can send DNS queries to
the server.
• A forwarders directive that defines what DNS servers this server will forward
recursive queries to.
• A recursion directive that allows recursive DNS queries to the server
To make those changes, open /etc/bind/named.conf.options in a text editor
Edit the named.conf.options file

#gedit /etc/bind/named.conf.options

After you make the changes, check the syntax of the file with the named-checkconf command:
#named-checkconf /etc/bind/named.conf.options
Note: If the syntax is correct, the command should not return any output.
Now update named service
#named -V
# ss -lnptu | grep named
#ufw allow in from 10.0.2.0/24 to any port 53
#ufw allow in from 192.168.121.0/24 to any port 53

#systemctl restart named


#systemctl enable named

The DNS main configuration directory is /etc/bind.


It contains the zone-lookup files
The global DNS configuration file is located at /etc/bind/named.conf.
For local configuration, we use the next file instead: /etc/bind/named.conf.local.
The named.conf.local is typically used to define local DNS zones for a private domain. We will
update this file to include our forward and reverse DNS zones.
Create forward and reverse zones in the file:

• esprit.tn is the zone name.


• esprit.tn.rev is the name of the forward lookup zone.
4. Configure Bind DNS zone lookup files

Next, we'll create a directory to store the zone files we specified in the previous step.
Mkdir/etc/bind/zones

• Create the forward zone lookup file

Now, we'll create a corresponding zone file /etc/bind/zones/esprit.tn. The forward zone file
allows the Bind DNS server to resolve names (like bindserver. esprit.tn) to IP addresses (like
10.0.2.15).

First, copy the default db.local zone file to /etc/bind/zones/ esprit.tn:


#cp /etc/bind/db.local /etc/bind/zones/esprit.tn
#gedit /etc/bind/zones/esprit.tn
Note: the zone file syntax, domain names should end with a dot (.)

The acronyms on the file have the following description:


• SOA – Start of Authority
• NS – Name Server
• A – A record
• MX – Mail for Exchange
• CN – Canonical Name

• Create the reverse zone lookup file

Now, we'll create a corresponding reverse zone file /etc/bind/zones/ esprit.tn.rev. The reverse
zone file allows the Bind DNS server to resolve IP addresses (like 10.0.2.15) to names (like
bindserver.esprit.tn). First, copy the default db.local zone file to /etc/bind/zones/ esprit.tn.rev
#cp /etc/bind/db.127 /etc/bind/zones/esprit.tn.rev

Open /etc/bind/zones/esprit.tn.rev in a text editor and make the changes indicated in the figure
below:
#gedit /etc/bind/zones/esprit.tn.rev
Note: The acronyms in the revese zone file are:

• PTR – Pointer
• SOA – Start of Authority

5. Check BIND DNS syntax


The named-checkconf command is used to check if the syntax is okay or if there is any error.
The command should return to shell if there is no error

sudo named-checkconf

The named-checkzone command is used to check the syntax of the forward and reverse zone
files:

#forward zone file

sudo named-checkzone esprit.tn /etc/bind/zones/esprit.tn

#reverse zone file


sudo named-checkzone esprit.tn.rev /etc/bind/zones/esprit.tn.rev

The output should be:

Finally restart BIND service:

6. Updating Bind DNS Records


A DNS record should be updated in both the /etc/bind/zones files.

#systemctl restart named


#systemctl enable named
#systemctl restart bind9
#systemctl status bind9

7. Testing the DNS Server


Let’s test our DNS resolution using the dig command. The dig command is used to get the information
about a domain name, this includes things like the DNS server, the IP of the domain, the MX records,
etc.

Sudo dig -a www.esprit.tn @10.0.2.15


To check the reverse DNS: use dig -x your_ip_address
#dig -x 10.0.2.15

This is a working proof that both the forward and reverse zone lookups are working fine.

8. Integration Part
After testing the DNS server using DIG command now try to test the function of the four
sites created in TP1(web server) add the modification needed and check it using the browser.
On any client machine, change its DNS server to our newly deployed server. In our case, it is
10.0.2.15

9. Conclusion
We have successfully deployed a local DNS server on Ubuntu 22.04. So as an administrator in
your local network, you can now manage your systems and applications. You could have your
applications communicating via the domain names. When IPs changes, you have to re-configure
your applications.

10. References
[1] web_link1: https://www.cherryservers.com/blog/how-to-install-and-configure-a-private-bind-
dns-server-on-ubuntu-22-04

[2] web_link2: https://askubuntu.com/questions/1297425/server-cant-find-servfail-bind9-dns-


server-setup

[3] web_link3 : https://www.linuxbabe.com/ubuntu/set-up-local-dns-resolver-ubuntu-20-04-


bind9

You might also like