How to Configure a Basic DNS Server with BIND

Have you ever wondered how websites like google.com or youtube.com show up when you type them into your browser? That’s where DNS comes in. DNS stands for Domain Name System. It’s like the phone book of the internet. Instead of remembering a long number (called an IP address), you just type a name like “google.com”, and DNS finds the right number for you.

In this article, I’ll walk you through setting up a simple DNS server using BIND. BIND stands for Berkeley Internet Name Domain. It’s one of the most popular tools for running a DNS server, and it’s free and open-source.

When I first started learning about servers, DNS felt confusing. But once I played with BIND, it made more sense. If I can do it, so can you.


Why Set Up Your Own DNS Server?

You might ask, “Why would I want to run a DNS server?” Good question.

Here are a few reasons:

  • You want to learn how the internet works behind the scenes.
  • You want full control over your domain name settings.
  • You’re managing a home lab or small business network.

It can also be fun. You can point your own domain names to any IP address. It’s like building your own tiny part of the internet.


What You’ll Need

Let’s keep it simple. Here’s what you need before we start:

  • A Linux server (Ubuntu, Debian, or CentOS work well)
  • Root or sudo access
  • A static IP address (not changing over time)
  • A little patience and curiosity

Don’t have a server? You can test everything on a virtual machine (VM) at home.


Step 1: Install BIND

First, we need to install BIND on your server.

On Debian or Ubuntu, run:

sudo apt update
sudo apt install bind9 bind9utils bind9-doc

On CentOS or Red Hat, run:

sudo yum install bind bind-utils

That’s it. The BIND software is now on your machine.


Step 2: Understand the BIND Files

Before we configure anything, let’s talk about the important files BIND uses. It helps to know what you’re editing.

Here are the main ones:

  • named.conf – This is the main configuration file. It includes other files.
  • named.conf.options – This file sets global options like DNS forwarding.
  • named.conf.local – This is where you define your own DNS zones.
  • zone files – These hold the actual records, like which IP a domain points to.

If these names seem strange, that’s okay. They become familiar over time.


Step 3: Configure Global Options

Now let’s set up some basic settings.

Open the named.conf.options file:

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

Find the section that looks like this:

options {
    directory "/var/cache/bind";

    recursion yes;
    allow-query { any; };

    forwarders {
        8.8.8.8;
        1.1.1.1;
    };

    dnssec-validation auto;
    auth-nxdomain no;    
    listen-on { any; };
};

Here’s what this does:

  • recursion yes – Lets clients ask your server to find answers.
  • forwarders – These are public DNS servers your server can use (Google and Cloudflare here).
  • listen-on { any; } – Listens on all network interfaces.

Save the file and exit.


Step 4: Create a Zone File

Now we’ll make your server respond to DNS queries for a specific domain.

Let’s say you own example.com.

First, edit the named.conf.local file:

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

Add this section:

zone "example.com" {
    type master;
    file "/etc/bind/zones/db.example.com";
};

Now create the directory and the zone file:

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

Paste this sample zone file:

$TTL    604800
@       IN      SOA     ns1.example.com. admin.example.com. (
                          2         ; Serial
                     604800         ; Refresh
                      86400         ; Retry
                    2419200         ; Expire
                     604800 )       ; Negative Cache TTL

; Nameservers
@       IN      NS      ns1.example.com.

; A records
ns1     IN      A       192.0.2.1
www     IN      A       192.0.2.1

Let me break that down:

  • SOA means Start of Authority. It tells who manages this zone.
  • NS is the name server.
  • A records map names to IPs.

Replace 192.0.2.1 with your real IP.


Step 5: Check Configuration

We want to be sure there are no mistakes.

Run this command:

sudo named-checkconf

No message = good. If there’s a mistake, BIND will tell you.

Next, check the zone file:

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

Again, you want to see something like:

zone example.com/IN: loaded serial 2
OK

Step 6: Start and Test BIND

Now let’s start the DNS service.

sudo systemctl restart bind9
sudo systemctl enable bind9

Check if it’s running:

sudo systemctl status bind9

Looks good? Let’s test it.

Run:

dig @localhost example.com

You should see an answer with your IP address.

Or, test it from another computer on the same network:

dig @192.0.2.1 example.com

Replace with your real IP.


Step 7: Set Your Client to Use Your DNS Server

Now try pointing your computer or phone to use your new DNS server.

You’ll need to go into your network settings and change the DNS to your server’s IP. Once that’s done, open your browser and try going to http://example.com. If you added a web server too, it should load. If not, try pinging it:

ping example.com

Some Things You Can Try Next

After you have a basic DNS server running, there’s a lot more you can explore.

Here are a few ideas:

  • Add reverse DNS (so IPs point back to names).
  • Set up a secondary/slave server.
  • Add more records: MX for mail, CNAMEs for aliases, and TXT for info.

Want to learn more? Try adding a subdomain like blog.example.com and point it somewhere else.


Comparing Public vs. Private DNS

When I started using my own DNS server, I noticed a few things compared to public ones like Google DNS:

Feature Public DNS Your Own DNS Server
Speed Often fast Can be faster on LAN
Control Very limited Full control
Privacy Logged by others You keep logs (or not)
Setup time Instant Takes effort
Learning opportunity None Tons of learning

I personally enjoy the control and learning that comes with my own DNS setup.


Common Problems and Fixes

Sometimes it doesn’t work right away. That’s normal. Here are some quick checks:

  • Firewall blocking port 53? Make sure TCP and UDP 53 are open.
  • Did you mistype an IP or domain? Triple-check your files.
  • Is your DNS service running? Use systemctl status.

Also, use journalctl -xe to look at error logs. They can give clues.


Final Thoughts

Running a DNS server with BIND may sound hard at first, but it’s a great skill to have. You learn how networks work and how the web finds websites.

I’ve made mistakes setting this up, but each one helped me learn. It’s kind of like building your own map of the internet.

So, what will you name your first domain?

Would you set this up on your home server, or maybe in a cloud VM?

Either way, I hope this guide helped you feel more confident about DNS and BIND.

Want help with setting up reverse DNS or mail records next?

Leave a Reply