BIND (Berkeley Internet Name Domain) is a popular open-source DNS server that is used to host DNS zones and resolve DNS queries. In this article, we will guide you through the process of configuring BIND as a private network DNS server on Ubuntu 20.04.

Before we begin, make sure that you have a fresh installation of Ubuntu 20.04 and that BIND is installed on your system. You will also need to be logged in as a user with sudo privileges.

Create a new zone file

The first step is to create a new zone file for your private network. A zone file is a file that contains DNS records for a specific domain or subdomain. To create a new zone file, open a terminal and run the following commands:


sudo mkdir /etc/bind/zones
sudo nano /etc/bind/zones/private.zone

This will create a new directory for the zone files and open a new file called "private.zone" in the editor.

Configure the zone file

In the "private.zone" file, add the following configuration:


$TTL 604800
@ IN SOA ns1.private.zone. admin.private.zone. (
  2  ; serial
  604800  ; refresh
  86400   ; retry
  2419200 ; expire
  604800 ) ; minimum

@ IN NS ns1.private.zone.
@ IN A 10.0.0.1
ns1 IN A 10.0.0.1

This configuration defines the domain name and DNS server for your private network. The "TTL" value specifies how long DNS clients should cache the DNS records before querying the server again. The "SOA" value defines the domain name and email address of the DNS server administrator. The "NS" and “A” values define the DNS server and its IP address.

Save the file and exit the editor.

Configure BIND

Next, we need to configure BIND to use the zone file that we just created. To do this, open the BIND configuration file using the following command:


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

In the file, add the following lines:


zone "private.zone" {
  type master;
  file "/etc/bind/zones/private.zone";
};

This tells BIND to use the "private.zone" file as the authoritative source for the "private.zone" domain. Save the file and exit the editor.

Restart BIND

After making changes to the BIND configuration, we need to restart the BIND service for the changes to take effect. To do this, run the following command in the terminal:


sudo systemctl restart bind9

Test DNS resolution

To verify that DNS resolution is working properly, use the "dig" command to query the DNS server for the "ns1.private.zone" domain. For example:


dig ns1.private.zone

If the DNS server is configured correctly, you should see the DNS records for the "ns1.private.zone" domain in the output.