Quick Reference

Cheatsheets

Practical command references for Linux, networking, servers, containers, databases, and more.

Cheatsheet#bind-cheatsheet

BIND Cheatsheet

BIND (Berkeley Internet Name Domain) is the most widely used Domain Name System (DNS) software on the internet.

Installation

# Debian / Ubuntu
sudo apt install bind9 bind9-utils
 
# RHEL / CentOS / Fedora
sudo dnf install bind bind-utils
 
# Arch Linux
sudo pacman -S bind

Service Management

# Debian / Ubuntu (service name: bind9)
sudo systemctl enable --now bind9
sudo systemctl restart bind9
sudo systemctl reload bind9           # Reload config without dropping queries
sudo systemctl status bind9
 
# RHEL / CentOS (service name: named)
sudo systemctl enable --now named
sudo systemctl restart named
sudo systemctl reload named
sudo systemctl status named

Configuration Checking

Always validate before reloading.

# Check main configuration syntax (named.conf)
named-checkconf /etc/bind/named.conf
 
# Check with all included files (quiet mode — no output means success)
named-checkconf -z
 
# Check a specific zone file
# Usage: named-checkzone <zone-name> <zone-file>
named-checkzone example.com /etc/bind/zones/db.example.com

Control Commands (rndc)

rndc communicates with the running BIND daemon.

rndc reload                            # Reload all configuration and zones
rndc reload example.com                # Reload a specific zone only
rndc reconfig                          # Reload config file only (picks up new zones)
rndc status                            # Show server status and statistics
rndc flush                             # Flush the entire DNS cache
rndc flush example.com                 # Flush cache for a specific domain
rndc stop                              # Gracefully stop the DNS server

Configuration File Locations

  • Debian / Ubuntu:
    • Main Config: /etc/bind/named.conf
    • Options: /etc/bind/named.conf.options
    • Local Zones: /etc/bind/named.conf.local
  • RHEL / CentOS:
    • Main Config: /etc/named.conf
    • Zone Files: /var/named/

Zone Definition (named.conf.local)

zone "example.com" {
    type master;
    file "/etc/bind/zones/db.example.com";
    allow-transfer { 192.168.1.5; };       // IP of secondary nameserver
};
 
zone "1.168.192.in-addr.arpa" {
    type master;
    file "/etc/bind/zones/db.192.168.1";   // Reverse lookup zone
};

Zone File Example (db.example.com)

$TTL    604800
@       IN      SOA     ns1.example.com. admin.example.com. (
                              3         ; Serial (increment on every change)
                         604800         ; Refresh (secondary checks primary)
                          86400         ; Retry (secondary retries on failure)
                        2419200         ; Expire (secondary stops serving)
                         604800 )       ; Negative Cache TTL
;
@       IN      NS      ns1.example.com.
@       IN      NS      ns2.example.com.
@       IN      A       192.168.1.10
ns1     IN      A       192.168.1.10
ns2     IN      A       192.168.1.11
www     IN      A       192.168.1.20
mail    IN      A       192.168.1.30
@       IN      MX  10  mail.example.com.

Diagnostic Tools

# Basic DNS query
dig example.com
 
# Query a specific nameserver
dig @127.0.0.1 example.com
 
# Query specific record types
dig example.com MX
dig example.com TXT
dig example.com AAAA
 
# Reverse DNS lookup
dig -x 192.168.1.10
 
# Short answer only
dig +short example.com
 
# Trace the full DNS resolution path
dig +trace example.com

Logs

# Debian / Ubuntu
journalctl -u bind9 -f
 
# RHEL / CentOS
journalctl -u named -f

Resources