Master Linux DNS: Install, Configure, and Manage BIND Servers
This guide explains the fundamentals of DNS, how hostnames map to IP addresses, and provides step‑by‑step instructions for installing BIND on Linux, configuring master, slave, and cache servers, defining zones, and managing common DNS record types.
What DNS Does
Every IP address can have a hostname composed of one or more strings separated by dots, allowing users to remember meaningful names instead of numeric addresses. DNS translates these hostnames to IP addresses.
Using /etc/hosts
When no DNS server is available, each system keeps a local copy of hostname‑IP mappings in /etc/hosts. Editing this file can override DNS lookups; for example, adding 127.0.0.1 google.com. will make the local machine resolve google.com to itself.
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 subdomain www. The trailing dot represents the root zone, managed by 13 root name servers.
Types of DNS Servers
Master DNS server : Holds authoritative zone files.
Slave DNS server : Acts as a backup, receiving zone updates from the master.
Cache DNS server : Stores query results to reduce external lookups.
Installing BIND on Linux
For Red Hat‑based systems: dnf -y install bind For Debian‑based systems: apt-get install bind9 Start and enable the service:
systemctl start named systemctl enable namedConfiguring BIND
BIND uses /etc/named.conf as its main configuration file. Key statements include:
options : Global settings (working directory is /var/named).
logging : Define what to log.
zone : Define DNS zones.
include : Include additional files.
Defining a Master Zone
zone "likegeeks.com" {
type master;
file "likegeeks.com.db";
};The zone file resides in /var/named. For a domain example.org, the file would be /var/named/example.org.db.
Defining a Slave (Auxiliary) Zone
zone "likegeeks.com" {
type slave;
masters { <em>IP‑ADDRESS</em>; };
file "likegeeks.com.db";
};The masters list tells the slave where to pull the zone data from.
Defining a Cache Server
Three special zones are needed before adding a cache:
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";
};These enable the server to resolve root hints, localhost, and reverse lookups.
DNS Record Types
BIND zone files can contain the following records:
SOA – Start of Authority, defines zone metadata.
NS – Name server records.
A and AAAA – Address records for IPv4 and IPv6.
PTR – Pointer records for reverse lookups.
MX – Mail exchange records.
CNAME – Canonical name (alias) records.
TXT – Arbitrary text data.
Example SOA entry:
example.com. 86400 IN SOA ns1.example.com. mail.example.com. (
2017012604 ; serial
86400 ; refresh
7200 ; retry
3600000 ; expire
86400 ; minimum
);Example NS entry: IN NS ns1.example.com. Example A record: support IN A 192.168.1.5 Example PTR record: 192.168.1.5 IN PTR support.example.com. Example MX record: example.com. IN MX 10 mail. Example CNAME record: www IN CNAME whatever-bignameis Example TXT record:
example.com. IN TXT "YOUR INFO GOES HERE"TTL Settings
The $TTL directive at the top of /etc/named.conf sets the default time‑to‑live for records, e.g., 14400 seconds (4 hours).
Diagnosing Configuration Errors
Syntax errors (missing dots, spaces, etc.) can be spotted in the log file /var/log/messages using:
tail -f /var/log/messagesUseful Commands
host : Resolve a hostname or IP address.
host example.com host 192.168.1.5whois : Query domain ownership. whois example.com rndc : Securely control the name server.
rndc status rndc reload example.com rndc reconfigConfiguring the Resolver
The client resolver reads /etc/resolv.conf (or /etc/resolvconf/resolv.conf.d/ on Debian). It specifies the default search domain and the nameserver IP addresses.
Once BIND is running, the system can use the local DNS server for name resolution.
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.
