Operations 17 min read

Master Linux DNS Server: Installation, Configuration, and Management Guide

This comprehensive guide explains how DNS translates hostnames to IP addresses, covers the role of /etc/hosts, details domain name components, describes the three DNS server types, and provides step‑by‑step instructions for installing BIND, configuring master, slave, and cache zones, as well as managing records, TTL, and common troubleshooting commands on Linux.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Master Linux DNS Server: Installation, Configuration, and Management Guide

/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 is still consulted even if a DNS server exists, allowing local overrides before external queries.

Example: add 127.0.0.1 google.com to /etc/hosts and browse to google.com to see the local Apache index page instead of the real Google site.

Domain Names

A Fully Qualified Domain Name (FQDN) such as www.google.com consists of a top‑level domain (TLD) com, a second‑level domain google, and a third‑level subdomain www. The trailing dot (root) is implicit and managed by 13 root name servers worldwide.

Top‑Level Domains (TLDs)

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

Subdomains

Subdomains are prefixes of a domain, such as mail.google.com being a subdomain of google.com. Only the authoritative name server for the parent domain knows its subdomains.

DNS Server Types

Primary (Master) DNS Server

Stores authoritative zone files and answers queries for its domains.

Secondary (Slave) DNS Server

Acts as a backup, receiving zone updates from the master.

Cache DNS Server

Does not hold zone files; it caches responses from other servers to speed up repeated queries.

Setting Up a Linux DNS Server

We focus on the BIND package, which powers most DNS servers worldwide.

Installation commands:

dnf -y install bind          # on Red Hat/CentOS
apt-get install bind9        # on Debian/Ubuntu

Start and enable the service:

systemctl start named
systemctl enable named

Configuring BIND

BIND uses /etc/named.conf as its main configuration file. Key statements include options, logging, zone, and include. The working directory is /var/named.

Example zone definition for likegeeks.com (master):

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

For a slave zone:

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

Cache zones (root hint and localhost) are defined similarly, e.g.:

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

Zone files contain records such as SOA, NS, A, AAAA, PTR, MX, CNAME, and TXT.

SOA (Start of Authority)

Defines the primary name server, contact email, and timing parameters (serial, refresh, retry, expire, minimum).

example.com. IN SOA ns1.example.com. mail.example.com. (
    2017012604 ; serial
    86400      ; refresh
    7200       ; retry
    3600000    ; expire
    86400      ; minimum
)

NS (Name Server)

example.com. IN NS ns1.example.com.
example.com. IN NS ns2.example.com.

A / AAAA (Address)

support IN A 192.168.1.5

PTR (Pointer)

192.168.1.5 IN PTR support.example.com.

MX (Mail Exchange)

example.com. IN MX 10 mail.example.com.

CNAME (Canonical Name)

www IN CNAME whatever-bignameis.example.com.

TXT

example.com. IN TXT "YOUR INFO GOES HERE"

TTL (Time To Live)

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

Capturing Configuration Errors

Check /var/log/messages with tail -f /var/log/messages to see BIND errors after editing zone files or named.conf.

Useful Commands

host

Resolve a hostname or perform a reverse lookup:

host example.com
host 192.168.1.5

whois

whois example.com

rndc

Securely control the name server:

rndc status
rndc reload example.com
rndc reload
rndc reconfig

Linux DNS Resolver

Clients use /etc/resolv.conf (or /etc/resolvconf/resolv.conf.d/ on Debian) to specify the default search domain and nameserver IP addresses.

With BIND running, point your resolver to your own DNS server for local 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.

networkDNSServer 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.