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 bindService 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 namedConfiguration 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.comControl 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 serverConfiguration File Locations
- Debian / Ubuntu:
- Main Config:
/etc/bind/named.conf - Options:
/etc/bind/named.conf.options - Local Zones:
/etc/bind/named.conf.local
- Main Config:
- RHEL / CentOS:
- Main Config:
/etc/named.conf - Zone Files:
/var/named/
- Main Config:
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.comLogs
# Debian / Ubuntu
journalctl -u bind9 -f
# RHEL / CentOS
journalctl -u named -f