Step‑by‑Step Guide to Installing and Configuring a Linux BIND DNS Server
This article walks you through the fundamentals of DNS, explains the role of /etc/hosts, describes the three types of DNS servers, shows how to install BIND on Red Hat or Debian systems, and provides detailed configuration examples for master, slave, and cache zones along with essential record types and troubleshooting commands.
What DNS Does
Every IP address can have a human‑readable hostname composed of one or more labels separated by dots; DNS maps those hostnames to IP addresses so you don’t have to memorize numeric addresses.
Using /etc/hosts as a Local Name Table
On a Linux system the /etc/hosts file provides a static hostname‑to‑IP mapping that works even when no DNS server is reachable. Editing this file (e.g., adding 127.0.0.1 google.com.) lets you test name resolution locally.
Domain Name Structure
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 label www. The trailing dot represents the root zone, which is served by a set of 13 root name servers.
Types of DNS Servers
Primary (master) server : holds authoritative zone files.
Secondary (slave) server : receives zone data from the master for redundancy.
Cache (resolver) server : answers client queries from its cache and forwards unknown queries to upstream servers.
Installing BIND
On Red Hat‑based distributions: dnf -y install bind On Debian‑based distributions: apt-get install bind9 Start and enable the service:
systemctl start named systemctl enable namedBasic BIND Configuration ( /etc/named.conf )
The file uses four main statements:
options : global server settings.
logging : defines what is logged.
zone : declares DNS zones.
include : pulls in additional files.
Defining a Master Zone
Example for the domain likegeeks.com:
zone "likegeeks.com" {
type master;
file "likegeeks.com.db";
};The zone file resides in /var/named.
Defining a Slave Zone
Same zone name, but with type slave and a list of master IPs:
zone "likegeeks.com" {
type slave;
masters { 192.0.2.1; };
file "likegeeks.com.db";
};Defining Cache Zones
Three hint zones are typically added:
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";
};Common DNS Record Types
SOA (Start of Authority)
Defines the primary name server, contact email, and timing parameters.
example.com. 86400 IN SOA ns1.example.com. mail.example.com. (
2017012604 ; serial
86400 ; refresh
7200 ; retry
3600000 ; expire
86400 ; minimum
);NS (Name Server)
Specifies authoritative name servers for a zone.
IN NS ns1.example.com.
IN NS ns2.example.com.A / AAAA (Address)
Maps a hostname to an IPv4 or IPv6 address.
support IN A 192.168.1.5PTR (Pointer)
Provides reverse lookup from IP to hostname.
192.168.1.5 IN PTR support.example.com.MX (Mail Exchange)
Indicates mail server(s) for a domain; lower priority numbers are preferred.
example.com. IN MX 10 mail.example.com.CNAME (Canonical Name)
Creates an alias for another hostname.
www IN CNAME whatever-bignameisTXT
Stores arbitrary text, often used for verification.
example.com. IN TXT "YOUR INFO GOES HERE"RP (Responsible Person)
Links a domain to a contact mailbox.
example.com. IN RP mail.example.com. example.com.TTL (Time‑to‑Live)
The $TTL directive in named.conf sets the default cache duration for records, e.g., 14400 seconds (4 hours).
Debugging Configuration Errors
Syntax mistakes (missing dots, spaces, etc.) cause BIND to refuse to start. Check /var/log/messages with:
tail -f /var/log/messagesUseful Commands
host : query DNS records, e.g., host example.com or reverse lookup host 192.168.1.5.
whois : retrieve domain registration info, e.g., whois example.com.
rndc : control BIND securely; common usages: rndc status, rndc reload example.com, rndc reconfig.
Configuring the Resolver
Clients read /etc/resolv.conf (or /etc/resolvconf/resolv.conf.d/ on Debian) to find the DNS server IPs. Typical entries are:
search example.com
nameserver 192.0.2.53Conclusion
By installing BIND, defining master, slave, and cache zones, and populating them with proper SOA, NS, A, PTR, MX, CNAME, TXT, and TTL settings, you can run a fully functional Linux DNS server and troubleshoot it using standard log files and command‑line tools.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
ITPUB
Official ITPUB account sharing technical insights, community news, and exciting events.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
