How to Configure BIND9 DNS Server on Ubuntu 20.04

In this tutorial, we will walk through the installation and basic configuration of the BIND9 DNS server.

Install BIND9

The first thing you need to do is to update the package list and to install BIND9.

sudo apt update
sudo apt install bind9

After the installation process is complete, you can check if BIND9 is working.

nslookup google.com
The answer will be something like this:

Non-authoritative answer:
Name: google.com

BIND9 configuration

The DNS server works right after installation. You need to configure it according to your usage purposes. First, allow BIND9 to work through the firewall.

sudo ufw allow Bind9

The main configuration file is named.conf.options, let’s open it.

sudo nano /etc/bind/named.conf.options

Some of the available options are listed below. Add the necessary to the «options» directive.

The «listen-on» directive allows you to specify the networks that the DNS server will serve. Don’t write this or write «any;» to work for all addresses.

listen-on {;;

BIND9 only allows local queries by default. Add the necessary IP addresses to the «allow-query» directive or «any;» to allow all requests.

allow-query { any; };

Forwarders contain the IP addresses of DNS servers to which the request is redirected if our server does not contain the required data.

forwarders {;;

Save and close the file. Check the configuration:

sudo named-checkconf

If no errors appear, then everything is in order. Restart the service for the changes to take effect.

sudo systemctl restart bind9

BIND9 test

To check if the DNS server is working properly, enter the following command on any other remote computer. Replace dns-server-ip-address with the IP address of the DNS server.

nslookup ubuntu.com dns-server-ip-address

Server: dns-server-ip-address
Address: dns-server-ip-address#53
Non-authoritative answer:
Name: ubuntu.com

Now you have a working caching name server BIND9.

Next steps: