How to setup bind dns server on ubuntu vpsHere’s a step-by-step guide demonstrating how to setup BIND DNS server on Ubuntu VPS. This will walk you through installing BIND9, configuring it as a primary (master) DNS server, setting up a domain zone, and ensuring it runs securely and correctly.

What is BIND DNS?

BIND (Berkeley Internet Name Domain) is the most widely used DNS server software on the Internet. It acts as the backbone of DNS (Domain Name System) services, resolving domain names into IP addresses and vice versa.

What Does BIND DNS Do?

BIND allows you to:

  • Host authoritative DNS zones (e.g., for example.com)
  • Perform recursive DNS queries (if configured)
  • Handle forward and reverse DNS lookups
  • Serve as primary (master) or secondary (slave) DNS server
  • Support features like DNSSEC, TSIG, and views

How It Works

  • You configure zone files with mappings like:
  • example.com → 192.0.2.1 (A record)
  • 192.0.2.1 → example.com (PTR record)
  • BIND responds to DNS queries for those zones.
  • You can also configure it to forward or recursively resolve external queries (like a caching resolver).

Core BIND Components

File / Feature Role
named The BIND daemon
named.conf Main config file
named.conf.local Zone definitions
named.conf.options Global options (like recursion settings)
Zone files Hold actual DNS records

Use Cases

  • Hosting your own DNS for a website
  • Running internal DNS for a LAN or enterprise
  • Acting as a caching resolver
  • Building a DNS infrastructure with master/slave or split-horizon DNS

Why Use BIND?

  • Open-source and widely supported
  • Highly configurable and powerful
  • Proven, stable, and trusted in production environments

Prerequisites

  • Ubuntu 24.04 VPS
  • Root access or a user with sudo privileges
  • A registered domain (e.g., example.com)
  • Your VPS’s public IP address (e.g., 192.0.2.1)

Launch 100% ssd ubuntu vps from $2. 49/mo!

How to Setup BIND DNS Server on Ubuntu VPS

To setup BIND DNS server on Ubuntu VPS, follow the steps provided below:

  1. Install BIND9

    Update your package list and install BIND9 and its utilities.

    sudo apt update sudo apt install bind9 bind9utils bind9-doc dnsutils -y

    Enable and start the BIND service:

    sudo systemctl enable named sudo systemctl start named
  2. Configure BIND9

    1. Define Your Zone in named.conf.local

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

      Add the following block (replace with your actual domain and zone file path):

      zone "example.com" { type master; file "/etc/bind/zones/db.example.com"; allow-transfer { none; }; };
    2. Create the Zones Directory

      sudo mkdir /etc/bind/zones
  3. Create the Forward Zone File

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

    Paste this template and adjust accordingly:

    $TTL    604800
    @       IN      SOA     ns1.example.com. admin.example.com. (
    3         ; Serial
    604800         ; Refresh
    86400         ; Retry
    2419200         ; Expire
    604800 )       ; Negative Cache TTL
    ;
    @       IN      NS      ns1.example.com.
    @       IN      A       192.0.2.1
    ns1     IN      A       192.0.2.1
    www     IN      A       192.0.2.1
    

    Explanation:

    • ns1.example.com. is your name server
    • admin.example.com. is your email (replace @ with .)
    • www and @ point to your VPS IP
  4. Verify Configurations

    1. Check Syntax:

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

      Fix any errors if they appear.

  5. Restart BIND9

    sudo systemctl restart named
  6. Configure Domain Registrar

    At your domain registrar:

    • Set your domain’s nameserver to your VPS (e.g., ns1.example.com)
    • Create a glue record (A record) for ns1.example.com pointing to 192.0.2.1
  7. Test the DNS Server

    Use dig to test:

    dig @192.0.2.1 example.com dig @192.0.2.1 www.example.com

    You should see a proper A record response for each.

  8. Harden the Server (Optional but Recommended)

    1. Limit Recursion (no open resolver):

      Edit /etc/bind/named.conf.options:

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

      Inside the options {} block, add:

      recursion no; allow-query { any; };

      Restart BIND:

      sudo systemctl restart named

Launch 100% ssd ubuntu vps from $2. 49/mo!

Conclusion

You now know how to setup BIND DNS server on Ubuntu VPS.

Share this:
Avatar of editorial staff

Editorial Staff

Rad Web Hosting is a leading provider of web hosting, Cloud VPS, and Dedicated Servers in Dallas, TX.
lg