This tutorial will cover how to set up an internal DNS server using the BIND name server software (BIND9) on Ubuntu 18.04 (install bind on Ubuntu) that your servers can use to resolve private hostnames and private IP addresses.

BIND (Berkely Internet Name Domain) is a popular software for translating domain names into IP addresses and is usually found on Linux VPS & Dedicated Servers. This article will explain the basic concepts of DNS BIND and analyze the associated files required to successfully set up your DNS BIND server.

Install BIND on Ubuntu 18.04

Before we install BIND, we will enter the following command to update the repository packages.

sudo apt-get update

Now that the packages are updated, we can enter the following command to install BIND 9 from the official Ubuntu package repository.

sudo apt-get install bind9

Once the installation completes, you will see a success message as follows:

* Starting domain name service... bind9      [OK]

BIND configurations

Now that we have successfully installed BIND on the server, the next step is to make the appropriate configurations. The following configurations are done to resolve your domain to the server. First, we will enter the named.conf.local file using the nano command:

nano /etc/bind/named.conf.local

Enter the following configurations into the file:

zone "" {
type master;
file "/etc/bind/zones/";
allow-transfer {; };
zone "" {
type master;
file "/etc/bind/zones/";
allow-transfer {; };

However, note that in the above configuration text, you will need to make some changes that will be suitable for your server. Instead of, you should add your domain name and corresponding TLD.

Another thing to note is to replace the IP address ( with the IP address of your server. Once the necessary values have been updated, you can save and exit the nano text editor.

To do this Ctrl + x > y > Enter.

The configurations in the named.conf.local file has been completed. Now let’s move on to the next part, to make the database file. So first enter the bind directory using the cd command as follows:

cd /etc/bind

Create a new directory called “zones” inside it using this command:

mkdir zones

Enter the newly created directory and create the databases file. Be sure to change the with the name corresponding to you:

cd zones


Now in the opened text editor, add the following text:

; BIND data file for
$TTL 14400
@ IN SOA (
201006601 ; Serial
7200 ; Refresh
120 ; Retry
2419200 ; Expire
604800) ; Default TTL
ns1 IN A
ns2 IN A
mail IN A
ftp IN CNAME IN TXT "v=spf1 ip4: a mx ~all"
mail IN TXT "v=spf1 a -all"

As you can see here, you should replace the domain name ( with your domain name and then for the IP addresses, be sure to change it to your server IP address. If you have two IPs, you can replace “ns2 IN A” with your second IP address. Otherwise, simply use the same IP.

Once the necessary configurations have been updated, you can save and exit the nano text editor.

To do this Ctrl + x > y > Enter.

The next part of setting up BIND on Ubuntu 18.04 is to define the reverse DNS lookup. To do this, we will be editing another configuration file.

nano /etc/bind/zones/

Once the file is opened, enter the following text. Don’t forget to replace “” with your own server’s hostname.

@ IN SOA (
86400 );

Once the necessary configurations have been updated, you can save and exit the nano text editor.

To do this Ctrl + x > y > Enter.

As the final configuration, we will add a single line to the following configuration file:

nano /etc/resolv.conf

Add the following at the beginning of the configuration file before any text. (Replace with your domain name)


Save and exit the nano text editor by pressing Ctrl + x > y > Enter.

Now all the configurations are done, and BIND is ready to use. However, for extra measures, it is recommended to restart the BIND 9 service using the following command:

sudo systemctl restart bind9

Testing the DNS

Now we will try to test your server's DNS by adding a a tool known as “DNS Utility”. You can install this by entering the following command on your terminal:

apt-get install dnsutils

Once the installation is finished, enter the following:


If everything is set up correctly, you will see an output similar to the one below:

; <<>> DiG 9.11.3-1ubuntu1.15-Ubuntu <<>>
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 53995
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

; EDNS: version: 0, flags:; udp: 1232
;                    IN      A

;; ANSWER SECTION:             158     IN      A             158     IN      A

;; Query time: 17 msec
;; WHEN: Wed Jun 02 02:29:21 PDT 2021
;; MSG SIZE  rcvd: 71


This tutorial sets up BIND 9 on your Ubuntu 18.04 server. Note that once you set up BIND, you should also pay close attention to the BIND9 configurations and set it up according to the abovementioned steps. If you encounter any problems along the way, be sure to let us know in the comments below. 

People also read: