Operations 17 min read

How to Install and Configure a Linux DNS Server (BIND) Step‑by‑Step

This guide explains the fundamentals of DNS, walks through installing and configuring a BIND DNS server on Linux (both Red Hat and Debian based), details zone definitions, record types, and essential commands for testing and troubleshooting the server.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
How to Install and Configure a Linux DNS Server (BIND) Step‑by‑Step

What DNS Does

Every IP address can have a hostname composed of one or more strings separated by dots. Hostnames make it easier to remember devices without memorizing numeric IPs. DNS (Domain Name System) provides this translation service.

/etc/hosts File

When no DNS server is available, each system can keep a local copy of hostname‑to‑IP mappings in /etc/hosts. This file works even if a DNS server is down, and it can be used for local overrides before querying external DNS.

Domain Names

A Fully Qualified Domain Name (FQDN) such as www.google.com consists of a top‑level domain (TLD), a second‑level domain, and a third‑level (sub) domain. The trailing dot (e.g., www.google.com.) represents the root zone, managed by a set of 13 root name servers worldwide.

Top‑Level Domains (TLDs)

TLDs are classified by function or geography (e.g., .com, .org, country codes like .us, brand TLDs, and infrastructure TLD .arpa). Over 800 TLDs exist.

Subdomains

Subdomains are prefixes to a domain, such as mail.google.com, which are resolved by the domain’s authoritative name servers.

Types of DNS Servers

Primary (master) server : Holds authoritative zone files and answers queries for its zones.

Secondary (slave) server : Acts as a backup, receiving zone data from the primary.

Cache server : Stores query results temporarily to reduce load on authoritative servers.

Installing BIND on Linux

For Red Hat‑based distributions (e.g., CentOS):

dnf -y install bind

For Debian‑based distributions (e.g., Ubuntu):

apt-get install bind9

After installation, start and enable the service:

systemctl start named systemctl enable named

Configuring BIND

BIND uses /etc/named.conf as its main configuration file. Key directives include: options: Global settings (e.g., working directory /var/named). logging: Define what to log. zone: Define DNS zones. include: Include additional files.

Defining a Primary Zone

zone "likegeeks.com" { type master; file "likegeeks.com.db"; };

The zone file resides in /var/named. The filename matches the domain (e.g., example.org.db for example.org).

Defining a Secondary Zone

zone "likegeeks.com" { type slave; masters { IP_ADDRESS_LIST; }; file "likegeeks.com.db"; };

Defining a Cache Zone

Typical cache configuration includes root hints, a localhost zone, and a reverse lookup zone:

zone "." IN { type hint; file "root.hint"; }; zone "localhost" IN { type master; file "localhost.db"; }; zone "0.0.127.in-addr.arpa" IN { type master; file "127.0.0.rev"; };

DNS Record Types

SOA : Start of Authority – defines zone metadata.

NS : Name Server – specifies authoritative name servers.

A / AAAA : Address records for IPv4/IPv6.

PTR : Pointer – reverse lookup from IP to hostname.

MX : Mail Exchange – mail server priority and address.

CNAME : Canonical Name – alias for another hostname.

TXT : Arbitrary text, often used for SPF/DKIM.

TTL (Time‑to‑Live)

The $TTL directive in /etc/named.conf sets the default cache duration for records (e.g., 14400 seconds = 4 hours).

Diagnosing Configuration Errors

Check /var/log/messages for BIND errors using:

tail -f /var/log/messages

Testing with Host and Dig

Use the host command to verify forward and reverse lookups:

host example.com host 192.168.1.5

For more detailed queries, use dig.

Whois Lookup

Determine domain ownership with:

whois example.com

Managing BIND with rndc

The rndc tool securely controls the name server:

rndc status rndc reload example.com rndc reload rndc reconfig

Configuring the Linux Resolver

Clients use /etc/resolv.conf (or /etc/resolvconf/resolv.conf.d/ on Debian) to specify the DNS server IP and search domains.

Conclusion

By installing BIND, defining zones, and understanding record types and troubleshooting tools, you can set up a reliable Linux DNS server for both internal and external name resolution.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

networkLinuxDNSServer ConfigurationBIND
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.