Hosting + Ai Website Builder + Free Domain (3 Month Free Credit)
Shop Today

How to Create DNS on Linux Server: Step-by-Step Guide

Domain Name System (DNS) is a critical component of the internet, translating human-readable domain names into IP addresses that computers use to communicate. Running your own DNS server on Linux allows you to create DNS setups, control domain resolution, manage internal networks, and improve reliability and performance for hosted services.

Understand DNS on Linux Server

In this article, we’ll cover how to create DNS server on a Linux server. You’ll learn prerequisites, installation steps, configuring BIND (Berkeley Internet Name Domain), managing zones, testing, troubleshooting, and best practices. By the end, you’ll be able to deploy a fully functional DNS environment.

Prerequisites

Before setting up a DNS server, make sure your system meets these requirements:

  • A Linux server (Ubuntu, Debian, CentOS, RHEL) with root or sudo access.
  • A static IP address is assigned to the server.
  • Firewall configured to allow DNS traffic (TCP/UDP port 53).
  • Basic knowledge of Linux commands and networking.

Having these prerequisites ensures smooth installation and configuration.

What is DNS and Why Use It?

DNS acts as the “phonebook” of the Internet. Instead of remembering IP addresses like 192.168.1.10, users can use example.com. Running your own DNS server provides several benefits:

  • Full control: Manage your domain records internally or publicly.
  • Faster resolution: Reduce dependency on external DNS providers.
  • Security: Implement access controls, logging, and DNSSEC.
  • Internal networks: Resolve hostnames in private LAN environments.

Linux servers, especially using BIND, provide a stable and flexible platform for DNS management.

Create DNS Setups on Linux

Setting up your own DNS server on Linux gives you full control over domain name resolution for your network or hosted services. It improves reliability, allows internal network management, and can speed up access to frequently used domains. Below are the steps to create DNS setups on Linux:

  • Step 1: Update System Packages

Keep your server up to date:

sudo apt update && sudo apt upgrade -y    # Ubuntu/Debian
sudo yum update -y                        # CentOS/RHEL
  • Step 2: Install BIND DNS Server

BIND is the most popular DNS server software:

sudo apt install bind9 bind9utils bind9-doc -y   # Ubuntu/Debian
sudo yum install bind bind-utils -y              # CentOS/RHEL
  • Step 3: Verify Installation
named -v

You should see the BIND version confirming successful installation.

Configuring BIND on Linux

BIND (Berkeley Internet Name Domain) is the most widely used DNS server on Linux. Proper configuration ensures your DNS server resolves domain names accurately, manages zones efficiently, and provides reliable network and internet name resolution for your systems.

  • Step 1: Edit Main Configuration File

The main configuration file is /etc/bind/named.conf (Ubuntu/Debian) or /etc/named.conf (CentOS/RHEL).

  • Step 2: Define Zones

Create zone files for your domain. Example: /etc/bind/named.conf.local

zone "example.com" {
    type master;
    file "/etc/bind/zones/db.example.com";
};
  • Step 3: Create Zone File

Create the folder if it doesn’t exist:

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

Example zone file:

$TTL 604800
@   IN  SOA ns1.example.com. admin.example.com. (
        2023081901 ; 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.10
  • Step 4: Set Up Reverse DNS

Configure reverse lookup in /etc/bind/named.conf.local

zone "1.168.192.in-addr.arpa" {
    type master;
    file "/etc/bind/zones/db.192";
};

Create /etc/bind/zones/db.192 for reverse records.

Managing DNS Services on Linux

Managing DNS services on Linux ensures smooth domain resolution, server reliability, and proper handling of network queries for both internal and external clients.

  • Start/Restart BIND Service:
sudo systemctl start bind9      # Ubuntu/Debian
sudo systemctl restart named    # CentOS/RHEL
  • Enable at boot:
sudo systemctl enable bind9
sudo systemctl enable named
  • Check status:
sudo systemctl status bind9
sudo systemctl status named
  • Test DNS Resolution:
dig @localhost example.com
nslookup example.com 127.0.0.1

Proper management ensures DNS queries are resolved reliably.

Common DNS Issues and Fixes

DNS servers on Linux can face problems that affect domain resolution. Knowing how to fix DNS issues ensures reliable network performance.

  • BIND Fails to Start:

Check configuration syntax:

sudo named-checkconf
  • Zone File Errors:

Verify zone syntax:

sudo named-checkzone example.com /etc/bind/zones/db.example.com
  • Firewall Blocking DNS:

Allow TCP/UDP port 53:

sudo ufw allow 53
  • Incorrect Resolution:

Check /etc/resolv.conf or clear cache:

sudo systemd-resolve --flush-caches
sudo rndc flush

Regular checks help maintain stable and efficient DNS operations.

Conclusion

Creating DNS server on Linux gives you full control over domain resolution, improves performance, and enhances network security. By installing BIND, configuring master and reverse zones, managing services, and following best practices, you can maintain a reliable and secure DNS environment for your organization or projects.

For advanced configurations, troubleshooting, and updates, always refer to the official BIND documentation.

Himanshu Joshi

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top