How to Configure BIND DNS Server on Ubuntu 24.04 VPS

DNS (Domain Name System), the backbone of the internet, translates human-friendly domain names into computer-understandable IP addresses. BIND is the most popular DNS server software on Linux servers. It's known for its flexibility, reliability, and performance. Installing BIND on Ubuntu VPS 24.04 allows you to host domains and internal networks.

This guide will show you how to install, verify, and configure a BIND server on Ubuntu 24.04.

How to Configure BIND DNS Server on Ubuntu 24.04 VPS

Installing BIND DNS on Ubuntu 24.04 gives you complete control over domain resolution and email routing. Your server can be used as a reliable DNS system by configuring forward and reverse zones. Follow these steps, from installation to testing, to build a robust DNS system that will ensure faster name resolution, higher uptime, and professional domain management for applications or websites.

Step 1: Update Your System

Make sure that your system has been updated before installing any packages.

sudo apt update

Updates ensure that your Ubuntu VPS is running the latest stable packages and security patches for BIND.

Step 2: Install BIND9 and DNS Utilities

Install BIND and its utilities by using:

sudo apt install bind9 bind9utils bind9-dnsutils 

Here,

  • bind9: the main DNS server package.
  • bind9utils: provides configuration and debugging tools.
  • bind9-dnsutils: includes DNS query tools like dig and lookup.

Install the software and then start it.

sudo systemctl enable named.service

sudo systemctl start bind9

Check the status of your order:

sudo systemctl status bind9

Step 3: Configure the Primary DNS Zone

We will configure a forward-lookup zone to resolve domain names into IP addresses.

Edit the main configuration:

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

Replace example.com (your domain name) with the following zone definition:

zone "example.com" {

    type master;

    file "/etc/bind/db.example.com";

};

This tells BIND to act as the master DNS server for example.com and store zone data in the file /etc/bind/db.example.com.

Step 4: Create the Forward Zone File

Modify the template for your domain by copying and pasting it into the zone file:

sudo cp /etc/bind/db.local /etc/bind/db.example.com

Let’s edit the file:

sudo nano /etc/bind/db.example.com

You can edit it like this:

$TTL    604800

@       IN      SOA     ns1.example.com. admin.example.com. (

                              2         ; Serial

                         604800         ; Refresh

                          86400         ; Retry

                        2419200         ; Expire

                         604800 )       ; Negative Cache TTL

;

@       IN      NS      ns1.example.com.

@       IN      A       192.168.1.10

ns1     IN      A       192.168.1.10

www     IN      A       192.168.1.11

mail    IN      A       192.168.1.12

@       IN      MX      10 mail.example.com.

Here,

  • SOA (Start of Authority) defines the primary DNS server and admin contact.
  • NS specifies the name server record.
  • A records map hostnames to IPs.
  • MX defines mail exchange servers.

Step 5: Configure the Reverse DNS Zone

Reverse DNS maps IP addresses to hostnames. Edit the configuration file once more:

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

Add this to your forward zone.

zone "1.168.192.in-addr.arpa" {

    type master;

    file "/etc/bind/db.192.168.1";

};

Create the reverse zone file.

sudo cp /etc/bind/db.127 /etc/bind/db.192.168.1

Let’s edit:

sudo nano /etc/bind/db.192.168.1

Modify the following:

$TTL    604800

@       IN      SOA     ns1.example.com. admin.example.com. (

                              2

                         604800

                          86400

                        2419200

                         604800 )

;

@       IN      NS      ns1.example.com.

10      IN      PTR     ns1.example.com.

11      IN      PTR     www.example.com.

12      IN      PTR     mail.example.com.

This file defines Pointer (Pointer Records) that maps IP addresses (like 192.168.1.10) to hostnames.

Step 6: Check BIND Configuration Syntax

Verify your DNS configuration before restarting the DNS service:

sudo named-checkconf

sudo named-checkzone example.com /etc/bind/db.example.com

sudo named-checkzone 1.168.192.in-addr.arpa /etc/bind/db.192.168.1

Step 7: Restart and Enable the BIND Service

Restart BIND in order to apply the configuration.

sudo systemctl restart bind9

Step 8: Test the DNS Server

Use the dig command to test your setup:

dig @localhost example.com

The expected output should include your server's address in the REPLY SECTION.

You can also try a reverse lookup.

dig -x 192.168.1.10 @localhost

Your reverse zone configuration is correct if you see the domain name of your website in the response.

Step 9: Adjust the Firewall

Allow DNS traffic if UFW is active

sudo ufw allow 53/tcp

sudo ufw allow 53/udp

sudo ufw reload

Port 53 is used to query DNS over TCP and UDP.

Step 10: (Optional) Configure Secondary DNS Server

You can add this entry to the name med.conf.local of another VPS for redundancy.

zone "example.com" {

    type slave;

    masters { 192.168.1.10; };

    file "/var/cache/bind/db.example.com";

};

This setup replicates the zone data from your DNS master server to ensure continuous availability.

Conclusion

To configure a BIND DNS server on Ubuntu 24.04 VPS, start by updating your system using sudo apt update && sudo apt upgrade -y, then install BIND with sudo apt install bind9 bind9utils bind9-dnsutils -y. Configure your domain by editing /etc/bind/named.conf.local to define a zone, such as example.com, and create its zone file in /etc/bind/db.example.com with the necessary SOA, NS, A, and MX records.

For reverse DNS, add a reverse zone in the same file and create /etc/bind/db.192.168.1 with corresponding PTR records. Verify your configuration with sudo namedcheckconf and sudo namecheckzone. Then restart BIND using sudo systemctl start bind9. Test DNS resolution by using dig @localhost.com. This will ensure that your BIND DNS server works correctly.

If you’re looking for a Cheap VPS solution for your next project, consider trying our hosting services.