Operations 10 min read

Master Linux DNS: From Fundamentals to Advanced BIND9 Configuration

This guide walks Linux system administrators through DNS fundamentals, client configuration files, NetworkManager and systemd-resolved settings, BIND9 server installation and zone setup, plus advanced techniques like DNSSEC, DoH, split views, load balancing, troubleshooting tools, and security best practices.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Master Linux DNS: From Fundamentals to Advanced BIND9 Configuration

What is DNS?

DNS (Domain Name System) translates human‑readable domain names such as www.example.com into IP addresses like 192.0.2.1, enabling browsers to locate servers on the Internet.

How DNS Works

Query Process : The client first checks its local DNS cache.

Recursive Query : If the cache misses, the client asks the ISP’s DNS server to perform a recursive lookup.

Iterative Query : The ISP’s server queries root servers, then TLD servers, and finally authoritative servers until it finds the answer.

Response : The resolved IP address is returned to the client, allowing the browser to connect.

Linux DNS Configuration

1. /etc/resolv.conf

This file lists nameserver IPs and optional search domains. Example:

nameserver 8.8.8.8
nameserver 8.8.4.4
search example.com

Note: Many modern distributions generate this file dynamically; editing it directly may be discouraged.

2. NetworkManager

Desktop Linux often uses NetworkManager for DNS settings. You can modify DNS via the GUI or with nmcli:

nmcli con mod "Wired connection 1" ipv4.dns "8.8.8.8 8.8.4.4"

3. systemd-resolved

systemd‑resolved provides local caching and DNSSEC validation. Its configuration resides in /etc/systemd/resolved.conf.

4. /etc/hosts

Static host‑to‑IP mappings can be added here to override DNS lookups:

127.0.0.1   localhost
192.168.1.10   myserver.local

BIND9 DNS Server

1. Install BIND9

Debian/Ubuntu: sudo apt install bind9 CentOS/RHEL:

sudo yum install bind

2. Configure BIND9

The main configuration file is /etc/bind/named.conf (Debian) or /etc/named.conf (CentOS). A minimal options block and a zone definition look like:

options {
    directory "/var/cache/bind";
    recursion yes;
    allow-recursion { trusted; };
    listen-on { 192.168.1.100; };
    allow-transfer { none; };
};

zone "example.com" {
    type master;
    file "/etc/bind/db.example.com";
};

3. Create a Zone File

Example /etc/bind/db.example.com defining SOA, NS, and A records:

$TTL    604800
@       IN      SOA     ns1.example.com. admin.example.com. (
                  3     ; Serial
               604800   ; Refresh
                86400   ; Retry
              2419200   ; Expire
               604800 ) ; Negative Cache TTL

@       IN      NS      ns1.example.com.
@       IN      A       192.168.1.10
www     IN      A       192.168.1.10

4. Start and Enable the Service

sudo systemctl start named
sudo systemctl enable named

Advanced DNS Techniques

1. DNSSEC

Enables cryptographic validation of DNS responses. In BIND9, add to options:

options {
    dnssec-enable yes;
    dnssec-validation auto;
};

2. DNS over HTTPS (DoH)

Encrypts DNS queries using HTTPS. Tools such as cloudflared can be used as a DoH client on Linux.

3. Split DNS Views

Provide different answers to internal vs. external clients:

view "internal" {
    match-clients { 192.168.0.0/16; };
    zone "example.com" { type master; file "/etc/bind/internal/db.example.com"; };
};

view "external" {
    match-clients { any; };
    zone "example.com" { type master; file "/etc/bind/external/db.example.com"; };
};

4. DNS Load Balancing

Multiple A records for the same name create simple round‑robin load balancing:

www     IN      A       192.168.1.10
www     IN      A       192.168.1.11
www     IN      A       192.168.1.12

5. Reverse DNS

Map IP addresses back to hostnames. Define a reverse zone:

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

Corresponding zone file example:

$TTL    604800
@       IN      SOA     ns1.example.com. admin.example.com. (
                  1     ; Serial
               604800   ; Refresh
                86400   ; Retry
              2419200   ; Expire
               604800 ) ; Negative Cache TTL

@       IN      NS      ns1.example.com.
10      IN      PTR     www.example.com.

Diagnostic Tools

dig : Detailed DNS queries. Example: dig www.example.com nslookup : Interactive DNS lookup. Example: nslookup www.example.com host : Simple query tool. Example: host www.example.com tcpdump : Capture DNS traffic. Example:

sudo tcpdump -i eth0 port 53

Security Considerations

Regular Updates : Keep DNS server software patched.

Access Control : Restrict recursive queries to trusted clients to prevent abuse.

Monitoring : Log queries and set alerts for anomalies.

DNSSEC : Deploy DNSSEC to authenticate responses.

Server Separation : Isolate authoritative and recursive services when possible.

Conclusion

Understanding DNS internals and mastering its configuration on Linux—from client‑side settings to full BIND9 server deployment and advanced features—empowers system administrators to ensure reliable, secure name resolution, streamline troubleshooting, and optimize network performance.

securityNetworkingbind9system-administration
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

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.