DNS & BIND

A technical reference for the Domain Name System and the Berkeley Internet Name Domain — protocols, configuration, record types, security, and troubleshooting.

RFC 1035 BIND 9 DNSSEC DoH / DoT

Table of Contents

01 — DNS Fundamentals

Understanding the phone book of the internet

The Domain Name System (DNS) is a hierarchical, distributed database that translates human-readable domain names (such as example.com) into machine-readable IP addresses (such as 93.184.216.34). Without DNS, users would need to memorize numeric IP addresses for every website they visit.

🌐 Distributed Database

DNS data is not stored in one place. It is distributed across millions of name servers worldwide. No single server holds all DNS records — each is authoritative for its own portion (zone) of the namespace.

🗂 Hierarchical Structure

The DNS namespace is organized as an inverted tree. The root is at the top, followed by Top-Level Domains (TLDs), second-level domains, and so on. Each level delegates authority to the level below it.

Caching & Performance

DNS resolvers cache responses based on the TTL (Time To Live) value. This dramatically reduces query load and latency. Most DNS lookups are resolved from cache without contacting authoritative servers.

🔒 Security Extensions

DNSSEC adds cryptographic signatures to DNS records, allowing resolvers to verify that responses have not been tampered with. This protects against cache poisoning and man-in-the-middle attacks.

💡
Key Concept: DNS operates primarily over UDP on port 53 for standard queries, and TCP on port 53 for zone transfers and responses larger than 512 bytes (or 4096 bytes with EDNS0). Modern DNS also uses TCP/443 (DoH) and TCP/853 (DoT).

Core DNS Components

  • Stub Resolver — The client-side library (e.g., libc) that sends DNS queries from applications. It typically forwards queries to a configured recursive resolver.
  • Recursive Resolver — A server (like your ISP's or 8.8.8.8) that resolves queries on behalf of clients by traversing the DNS tree from root to authoritative.
  • Authoritative Server — A server that holds the actual DNS records for a zone and provides definitive answers to queries for that zone.
  • Root Server — One of 13 root server clusters (A through M) that direct queries to the appropriate TLD server.
  • TLD Server — Handles queries for top-level domains (.com, .org, .net, etc.) and points to authoritative servers for second-level domains.
  • Forwarder — A DNS server that forwards queries it cannot resolve locally to another resolver, rather than performing full recursion itself.

02 — DNS Hierarchy

A tree rooted at a single dot

DNS Namespace Tree
                              . (root)
                              │
            ┌─────────────────┼─────────────────┐
            │                 │                  │
          .com              .org               .net
            │                 │                  │
      ┌─────┼─────┐      ┌───┴───┐          ┌───┴───┐
      │     │     │      │       │          │       │
   google example amazon  wikipedia  apache    cloudflare  ...
      │     │                │
   ┌──┴──┐  │            ┌──┴──┐
   │     │  │            │     │
  www   mail www         en    de
   │     │  │            │     │
 A rec  MX  A rec      A rec  A rec

Every fully qualified domain name (FQDN) ends with a dot representing the root. When you type www.example.com, the FQDN is actually www.example.com. (with trailing dot). Each label between dots can be up to 63 characters long, and the total FQDN can be up to 253 characters.

Root Zone

The root zone is managed by IANA (under ICANN) and served by 13 root server identities (A.root-servers.net through M.root-servers.net). In reality, these are distributed across 1,700+ instances worldwide using anycast routing. The root zone file is relatively small and only contains delegations to TLD servers.

Top-Level Domains

TLDs fall into several categories: gTLDs (generic: .com, .org, .net, .info), ccTLDs (country-code: .uk, .de, .jp), sTLDs (sponsored: .edu, .gov, .mil), and new gTLDs (.app, .dev, .cloud). Each TLD is operated by a designated registry operator (e.g., Verisign for .com).

03 — Name Resolution Process

How a domain name becomes an IP address

Iterative DNS Resolution Flow
  User types                    ┌──────────────┐
  www.example.com ──────────►   │  Stub        │
                                │  Resolver    │
                                └──────┬───────┘
                                       │ Query: www.example.com?
                                       ▼
                                ┌──────────────┐
                            ┌── │  Recursive   │ ◄── Checks cache first
                            │   │  Resolver    │
                            │   └──────┬───────┘
                            │          │
              Cache miss ───┘          │ Step 1: Query root server
                                       ▼
                                ┌──────────────┐
                                │  Root Server │ ─── "I don't know, but
                                │  (.)         │      ask .com servers"
                                └──────────────┘
                                       │ Returns NS for .com
                                       ▼
                                ┌──────────────┐
                                │  TLD Server  │ ─── "I don't know, but
                                │  (.com)      │      ask example.com NS"
                                └──────────────┘
                                       │ Returns NS for example.com
                                       ▼
                                ┌──────────────┐
                                │ Authoritative │ ─── "Here's the answer:
                                │ (example.com) │      93.184.216.34"
                                └──────────────┘
                                       │
                                       ▼
                               Response cached (TTL)
                               Answer returned to client

Resolution Types

🔄 Recursive Query

The client demands a complete answer. The recursive resolver must either return the answer or an error — it cannot return a referral. This is the typical mode between stub resolvers and recursive resolvers.

Iterative Query

The server returns the best answer it has, which may be a referral to another server. The querier is then responsible for following the referral. This is how recursive resolvers talk to authoritative servers.

💾 Inverse Query (deprecated)

Originally specified in RFC 1035, inverse queries mapped an answer back to a question (e.g., IP to name). This was replaced by the much more practical reverse DNS system using PTR records in the in-addr.arpa and ip6.arpa zones.

DNS Packet Structure (RFC 1035 §4): Every DNS message contains a 12-byte header with fields: ID (16-bit), QR flag (query/response), Opcode, AA/TC/RD/RA flags, RCODE, and counts for Question/Answer/Authority/Additional sections.

04 — Resource Record Types

The building blocks of DNS data

Every DNS record follows the format: name TTL class type rdata. The class is almost always IN (Internet). Here are the essential record types:

TypeRFCPurposeExample
A1035Maps a name to an IPv4 addresswww IN A 93.184.216.34
AAAA3596Maps a name to an IPv6 addresswww IN AAAA 2606:2800:220:1:...
CNAME1035Canonical name (alias) for another nameblog IN CNAME www.example.com.
MX1035Mail exchange server with priority@ IN MX 10 mail.example.com.
NS1035Authoritative name server for the zone@ IN NS ns1.example.com.
PTR1035Pointer for reverse DNS lookups34 IN PTR www.example.com.
SOA1035Start of Authority — zone metadataSee zone file example below
TXT1035Arbitrary text (SPF, DKIM, DMARC, etc.)@ IN TXT "v=spf1 mx -all"
SRV2782Service locator (port, priority, weight)_sip._tcp IN SRV 10 60 5060 sip.example.com.
CAA8659Certificate Authority Authorization@ IN CAA 0 issue "letsencrypt.org"
NAPTR3403Naming Authority Pointer (ENUM, SIP)Used in VoIP and ENUM applications
DNSKEY4034Public key for DNSSECContains the zone signing key
DS4034Delegation Signer for DNSSEC chainHash of child zone's DNSKEY
RRSIG4034DNSSEC signature over an RRsetCryptographic signature data
SVCB9460Service Binding (general)Modern alternative to SRV
HTTPS9460HTTPS-specific service binding@ IN HTTPS 1 . alpn="h2,h3"

SOA Record Deep Dive

The SOA record is mandatory for every zone and defines key parameters:

Zone File — SOA Record
example.com.  IN  SOA  ns1.example.com. admin.example.com. (
    2024010101  ; Serial number (YYYYMMDDNN format)
    3600        ; Refresh — secondary checks primary every 1 hour
    900         ; Retry — if refresh fails, retry every 15 min
    1209600     ; Expire — secondary stops serving after 14 days
    86400       ; Minimum TTL — negative caching TTL (1 day)
)
Common Mistake: The "admin email" in the SOA record uses a dot instead of @. So admin.example.com. actually means admin@example.com. If the local part contains a dot, escape it with a backslash: first\.last.example.com.

05 — Zones & Zone Files

Administrative boundaries in DNS

Zone vs. Domain

A domain is a subtree of the DNS namespace (e.g., example.com and everything below it). A zone is a contiguous portion of the namespace managed by a single administrator. Zones are defined by delegation — when you create NS records for sub.example.com, you create a new zone with its own SOA and authority.


The domain example.com might contain the subdomain internal.example.com, but if internal.example.com is delegated to different name servers, they are in separate zones.

Zone Transfer

AXFR (Full Zone Transfer, RFC 5936): The secondary server requests the entire zone from the primary. Used for initial synchronization.


IXFR (Incremental Zone Transfer, RFC 1995): Only the changes since a given serial number are transferred. Far more efficient for large zones with small changes.


NOTIFY (RFC 1996): The primary server immediately notifies secondaries when the zone changes, rather than waiting for the SOA refresh interval.

Complete Zone File Example

Zone File — /var/named/zones/db.example.com
$ORIGIN example.com.
$TTL 86400

; === SOA Record ===
@   IN  SOA  ns1.example.com. hostmaster.example.com. (
        2024010301  ; Serial
        3600        ; Refresh (1 hour)
        900         ; Retry (15 minutes)
        1209600     ; Expire (2 weeks)
        86400       ; Minimum / Negative Cache TTL
    )

; === Name Servers ===
@       IN  NS   ns1.example.com.
@       IN  NS   ns2.example.com.

; === Mail ===
@       IN  MX   10 mail.example.com.
@       IN  MX   20 mail-backup.example.com.

; === A Records ===
@       IN  A       93.184.216.34
ns1     IN  A       93.184.216.1
ns2     IN  A       93.184.216.2
www     IN  A       93.184.216.34
mail    IN  A       93.184.216.10

; === AAAA Records ===
@       IN  AAAA    2606:2800:220:1:248:1893:25c8:1946
www     IN  AAAA    2606:2800:220:1:248:1893:25c8:1946

; === CNAME Records ===
blog    IN  CNAME   www.example.com.
ftp     IN  CNAME   www.example.com.

; === TXT Records ===
@       IN  TXT     "v=spf1 mx ip4:93.184.216.0/24 -all"
_dmarc  IN  TXT     "v=DMARC1; p=reject; rua=mailto:dmarc@example.com"

; === SRV Records ===
_sip._tcp  IN  SRV  10 60 5060 sip.example.com.

; === CAA Record ===
@       IN  CAA  0 issue "letsencrypt.org"

06 — BIND — The Berkeley Internet Name Domain

The most widely used DNS server software

BIND (Berkeley Internet Name Domain) is an open-source DNS server originally written at the University of California, Berkeley in the 1980s. Now developed and maintained by the Internet Systems Consortium (ISC), BIND is the reference implementation for DNS and runs on the majority of the internet's name servers.

📦 BIND 9 Architecture

BIND 9 was a complete rewrite focused on modularity, security, and modern features. It consists of the named daemon (the actual server), rndc (remote control utility), and various zone management tools like dnssec-keygen and named-checkzone.

Key Features

  • Full recursive and authoritative support
  • DNSSEC signing and validation
  • Dynamic DNS updates (RFC 2136)
  • Response Rate Limiting (RRL)
  • TSIG/SIG(0) authentication
  • Views for split-horizon DNS
  • Catalog Zones for automated provisioning
  • GeoIP-based responses

🛠 BIND Utilities

  • named — The DNS daemon itself
  • rndc — Remote Name Daemon Control
  • dig — DNS lookup utility
  • nslookup — Legacy query tool
  • host — Simple DNS lookup
  • named-checkconf — Validate config syntax
  • named-checkzone — Validate zone files
  • dnssec-keygen — Generate DNSSEC keys

BIND Installation

Debian / Ubuntu
sudo apt update
sudo apt install bind9 bind9utils bind9-doc
sudo systemctl enable named
sudo systemctl start named
RHEL / CentOS / Fedora
sudo dnf install bind bind-utils
sudo systemctl enable named
sudo systemctl start named
sudo firewall-cmd --add-service=dns --permanent

07 — BIND Configuration

The named.conf file in depth

BIND is configured through named.conf (typically in /etc/named/ or /etc/bind/). The configuration file uses a C-like syntax with nested blocks.

named.conf — Full Example
// ==============================================
// BIND 9 Configuration — /etc/named/named.conf
// ==============================================

// Access Control Lists
acl "trusted" {
    10.0.0.0/8;
    172.16.0.0/12;
    192.168.0.0/16;
    localhost;
    localnets;
};

options {
    directory          "/var/named";
    pid-file           "/run/named/named.pid";
    dump-file          "/var/named/data/cache_dump.db";
    statistics-file    "/var/named/data/named_stats.txt";

    // Listen on interfaces
    listen-on port 53  { 127.0.0.1; 10.0.1.1; };
    listen-on-v6 port 53 { ::1; };

    // Recursion — only for trusted clients
    recursion yes;
    allow-recursion     { "trusted"; };
    allow-query         { any; };
    allow-transfer      { none; };

    // Forwarding
    forwarders {
        8.8.8.8;
        1.1.1.1;
    };
    forward only;

    // DNSSEC
    dnssec-validation auto;

    // Performance tuning
    max-cache-size     256M;
    max-cache-ttl      3600;
    max-ncache-ttl     300;

    // Rate limiting (anti-DDoS)
    rate-limit {
        responses-per-second 10;
        window 5;
    };

    // Query logging (disable in production)
    querylog no;
};

// Logging configuration
logging {
    channel default_log {
        file "/var/log/named/default.log" versions 5 size 50m;
        severity info;
        print-time yes;
        print-severity yes;
        print-category yes;
    };
    channel query_log {
        file "/var/log/named/queries.log" versions 3 size 100m;
        severity info;
        print-time yes;
    };
    channel security_log {
        file "/var/log/named/security.log" versions 5 size 50m;
        severity dynamic;
        print-time yes;
    };

    category default   { default_log; };
    category queries   { query_log; };
    category security  { security_log; };
};

// TSIG key for zone transfers
key "transfer-key" {
    algorithm hmac-sha256;
    secret "bWFzdGVyLXNlY3JldC1rZXktZm9yLXRyYW5zZmVycw==";
};

// Primary zone
zone "example.com" {
    type primary;
    file "zones/db.example.com";
    allow-transfer { key "transfer-key"; };
    also-notify { 10.0.2.1; };
    notify yes;
};

// Secondary zone
zone "partner.com" {
    type secondary;
    file "zones/db.partner.com";
    primaries { 203.0.113.10 key "transfer-key"; };
};

// Reverse DNS zone
zone "1.0.10.in-addr.arpa" {
    type primary;
    file "zones/db.10.0.1";
    allow-transfer { key "transfer-key"; };
};

// Root hints
zone "." {
    type hint;
    file "named.ca";
};

Configuration Blocks Explained

acl

Defines named lists of IP addresses/networks. Reusable throughout the configuration. Built-in ACLs include any, none, localhost, and localnets.

options

Global server settings: listening interfaces, recursion behavior, forwarders, cache size, DNSSEC, rate limiting, and file paths. These are the defaults unless overridden per-zone.

logging

Defines channels (output destinations) and categories (types of messages). Channels can write to files, syslog, stderr, or null. Essential for debugging and security monitoring.

zone

Defines each DNS zone the server is responsible for. Types include primary (authoritative master), secondary (slave), forward, stub, hint (root), and mirror.

key

Defines TSIG shared secrets used for authenticating zone transfers, dynamic updates, and rndc communication. Always use hmac-sha256 or stronger.

view

Enables split-horizon DNS — different clients see different zones/records based on their source IP. Useful for serving different internal vs. external records.

08 — BIND Zone Examples

Practical zone file configurations

Reverse DNS Zone (IPv4)

/var/named/zones/db.10.0.1
$ORIGIN 1.0.10.in-addr.arpa.
$TTL 86400

@   IN  SOA  ns1.example.com. hostmaster.example.com. (
        2024010101 3600 900 1209600 86400 )

@   IN  NS   ns1.example.com.
@   IN  NS   ns2.example.com.

; PTR records — map IP to hostname
1   IN  PTR  ns1.example.com.
2   IN  PTR  ns2.example.com.
10  IN  PTR  mail.example.com.
34  IN  PTR  www.example.com.

Split-Horizon DNS with Views

named.conf — Views Example
view "internal" {
    match-clients { "trusted"; };
    recursion yes;

    zone "example.com" {
        type primary;
        file "zones/internal/db.example.com";
    };
};

view "external" {
    match-clients { any; };
    recursion no;

    zone "example.com" {
        type primary;
        file "zones/external/db.example.com";
    };
};
💡
Split-Horizon Use Case: Internal users resolve app.example.com to a private IP (10.0.1.50) for direct access, while external users resolve it to the public IP (203.0.113.50) through a load balancer. Views must be defined in order — first match wins.

Dynamic DNS Update

Shell — nsupdate
# Using nsupdate with TSIG key
nsupdate -k /etc/named/keys/update-key.key <<EOF
server 10.0.1.1
zone example.com
update delete dynamic-host.example.com A
update add dynamic-host.example.com 300 A 10.0.1.100
send
EOF

09 — Advanced BIND Features

Going beyond the basics

🌍 Response Policy Zones (RPZ)

RPZ lets BIND act as a DNS firewall. You define policies that override normal DNS responses for specific domains — blocking malware domains, redirecting phishing sites, or implementing walled gardens. RPZ zones use special record types like CNAME to . (NXDOMAIN) or CNAME to *.rpz-passthru.

RPZ Zone
; Block a malware domain
malware.bad-site.com  CNAME  .

; Redirect phishing to warning page
phish.example.com  A  10.0.0.100

; Passthrough (whitelist)
safe.example.com  CNAME  *.rpz-passthru.

🔍 Catalog Zones (RFC 9432)

Catalog zones automate provisioning of zones on secondary servers. Instead of manually adding zone statements to every secondary's config, you add the zone to a "catalog" zone on the primary. Secondaries automatically pick up and serve the new zone.

Catalog Zone
catalog.example.com. IN SOA . . 1 3600 900 1209600 86400
catalog.example.com. IN NS invalid.
version.catalog.example.com. IN TXT "2"
; Add a member zone
<unique-id>.zones.catalog.example.com. IN PTR newzone.com.

🔄 RNDC — Remote Control

The rndc utility lets you control a running BIND instance without restarting:

Shell
rndc reload                  # Reload all zones
rndc reload example.com      # Reload specific zone
rndc flush                   # Flush entire cache
rndc flushname bad.com       # Flush specific name
rndc status                  # Server status
rndc querylog on             # Enable query logging
rndc dumpdb -all              # Dump cache to file
rndc signing -list example.com # List DNSSEC keys
rndc retransfer example.com  # Force zone transfer

🔧 BIND Performance Tuning

  • Worker threads: Set to match CPU cores for parallel query processing
  • max-cache-size: Allocate 50–75% of available RAM for caching
  • minimal-responses: Reduce response size by omitting unnecessary sections
  • prefetch: Proactively refresh popular records before TTL expiry
  • TCP clients: Tune tcp-clients for environments with many TCP queries
  • Serve-stale: Return expired cache entries while refreshing in background (RFC 8767)

10 — DNS Security

DNSSEC, DoH, DoT, and threat mitigation

DNSSEC — How It Works

DNSSEC adds a chain of trust from the root zone to each signed domain. Zone owners sign their records with private keys; resolvers verify signatures using the corresponding public keys published in DNS.

DNSSEC Chain of Trust
  Root Zone (.)
  ├── DNSKEY (KSK + ZSK) ── Signed by root KSK
  ├── RRSIG over DNSKEY
  └── DS record for .com ──── Hash of .com's KSK
         │
         ▼
  .com TLD Zone
  ├── DNSKEY (KSK + ZSK) ── Validated via DS in root
  ├── RRSIG over DNSKEY
  └── DS record for example.com
         │
         ▼
  example.com Zone
  ├── DNSKEY (KSK + ZSK) ── Validated via DS in .com
  ├── RRSIG over each RRset
  ├── A record + RRSIG ──── Verifiable!
  └── NSEC/NSEC3 ────────── Proof of non-existence

  KSK = Key Signing Key (signs DNSKEY RRset)
  ZSK = Zone Signing Key (signs all other RRsets)
  DS  = Delegation Signer (links parent to child)

DNSSEC with BIND

Shell — DNSSEC Key Generation & Zone Signing
# Generate Key Signing Key (KSK)
dnssec-keygen -a ECDSAP256SHA256 -f KSK example.com

# Generate Zone Signing Key (ZSK)
dnssec-keygen -a ECDSAP256SHA256 example.com

# Sign the zone
dnssec-signzone -A -3 $(head -c 1000 /dev/urandom | sha1sum | cut -b 1-16) \
  -N INCREMENT -o example.com -t db.example.com

# Or use BIND's inline-signing (automatic)
# In named.conf:
zone "example.com" {
    type primary;
    file "zones/db.example.com";
    dnssec-policy "default";
    inline-signing yes;
};

Common DNS Attacks & Mitigations

🚨 Cache Poisoning

Attack: An attacker sends forged responses to a resolver, replacing legitimate records with malicious ones (e.g., Kaminsky attack).

Mitigations: DNSSEC validation, source port randomization, 0x20 encoding (mixed-case query names), response rate limiting.

💥 DDoS Amplification

Attack: Open resolvers are abused to amplify traffic towards a victim. A small query with a spoofed source IP generates a large response sent to the victim.

Mitigations: Disable open recursion, implement RRL, BCP 38 (ingress filtering), use allow-recursion ACLs.

🕵 DNS Tunneling

Attack: Data exfiltration by encoding data in DNS queries/responses (e.g., encoded-data.evil.com TXT queries).

Mitigations: Monitor for unusual query patterns (high volume, long labels, high entropy), limit TXT record query rates, use RPZ.

🎭 Domain Hijacking

Attack: Taking control of a domain by exploiting weak registrar security, expired domains, or social engineering the registrar.

Mitigations: Registrar lock, DNSSEC, two-factor authentication, registry lock services, monitoring for unauthorized changes.

11 — Modern DNS Protocols

Encrypting and evolving DNS for the modern internet

🔒 DNS over HTTPS (DoH)

RFC 8484 — Encapsulates DNS queries in HTTPS requests to port 443. Provides confidentiality and makes DNS indistinguishable from regular web traffic. Supported by major browsers (Firefox, Chrome, Edge) and resolvers (Cloudflare, Google, Quad9).

curl — DoH Query
curl -sH 'accept: application/dns-json' \
  'https://cloudflare-dns.com/dns-query?name=example.com&type=A'

🔐 DNS over TLS (DoT)

RFC 7858 — Wraps standard DNS wire format in TLS on port 853. Easier to implement than DoH and simpler to deploy on existing infrastructure. Can be blocked by networks since it uses a dedicated port.

Shell — kdig (DoT query)
kdig +tls @1.1.1.1 example.com A
# Or with dig (BIND 9.18+)
dig +tls @1.1.1.1 example.com A

DNS over QUIC (DoQ)

RFC 9250 — Uses QUIC (UDP-based) on port 853 for encrypted DNS. Combines the privacy of DoT with the performance benefits of QUIC: 0-RTT connection resumption, multiplexed streams, and reduced latency.

🚀 Oblivious DNS (ODoH)

RFC 9230 — Adds a proxy layer between client and resolver so that the proxy knows the client but not the query, and the resolver knows the query but not the client. Full privacy separation.

ProtocolPortTransportRFCPrivacyFirewall Visibility
Classic DNS53UDP/TCP1035NoneFully visible
DoT853TLS7858EncryptedIdentifiable by port
DoH443HTTPS8484EncryptedBlends with HTTPS
DoQ853QUIC9250EncryptedIdentifiable by port
ODoH443HTTPS+Proxy9230Client-resolver unlinkableBlends with HTTPS

12 — DNS Troubleshooting & Command Reference

Every command you need for DNS diagnostics — click the copy button to copy any command

📋
Quick Tip: Click the clipboard icon on any command row below to copy it to your clipboard. Replace example.com with your target domain.

dig — The DNS Swiss Army Knife

Part of BIND utilities. The most powerful and flexible DNS query tool. Outputs full DNS response details including headers, flags, and all sections.

Basic Queries

dig
Fundamental lookups for common record types
dig example.com
Default A record lookup
dig example.com A
Explicit A record query
dig example.com AAAA
IPv6 address record
dig example.com MX
Mail exchange records
dig example.com NS
Name server records
dig example.com TXT
Text records (SPF, DKIM, etc.)
dig example.com SOA
Start of Authority record
dig example.com CNAME
Canonical name (alias)
dig example.com CAA
Certificate Authority Authorization
dig example.com ANY
All available records
dig _sip._tcp.example.com SRV
Service record lookup

Output Control

dig
Adjust verbosity and what dig shows you
dig +short example.com A
Terse output — IP only
dig +noall +answer example.com A
Show answer section only
dig +noall +answer +authority example.com NS
Answer + authority sections
dig +noall +answer +additional example.com NS
Answer + glue records
dig +stats example.com
Show query time and stats
dig +multiline example.com SOA
Readable multi-line SOA output
dig +yaml example.com A
YAML-formatted output (BIND 9.18+)

Server Selection & Transport

dig
Target specific servers and protocols
dig @8.8.8.8 example.com A
Query Google DNS
dig @1.1.1.1 example.com A
Query Cloudflare DNS
dig @9.9.9.9 example.com A
Query Quad9 DNS
dig @ns1.example.com example.com A
Query authoritative directly
dig +tcp example.com A
Force TCP transport
dig +tls @1.1.1.1 example.com A
DNS over TLS (BIND 9.18+)
dig +https @1.1.1.1 example.com A
DNS over HTTPS (BIND 9.18+)
dig -p 5353 @localhost example.com A
Query non-standard port

Advanced Diagnostics

dig
Tracing, reverse lookups, zone transfers, and DNSSEC
dig +trace example.com A
Full resolution trace root→TLD→auth
dig +trace +nodnssec example.com A
Trace without DNSSEC clutter
dig -x 93.184.216.34
Reverse DNS (IP → hostname)
dig -x 2606:2800:220:1::248
Reverse DNS for IPv6
dig +dnssec example.com A
Request DNSSEC records (RRSIG)
dig +cd +dnssec example.com A
Disable DNSSEC validation
dig example.com DNSKEY +multiline
View DNSSEC public keys
dig example.com DS
Delegation Signer records
dig +tcp @ns1.example.com example.com AXFR
Full zone transfer (if permitted)
dig @localhost version.bind CHAOS TXT
Query BIND version
dig +nsid @1.1.1.1 example.com A
Request Name Server ID
dig +subnet=203.0.113.0/24 example.com A
Test EDNS Client Subnet (ECS)

Email DNS Diagnostics

dig
Verify SPF, DKIM, DMARC, and MTA-STS records
dig example.com MX +short
Mail servers with priority
dig example.com TXT +short
Check SPF record
dig selector._domainkey.example.com TXT
DKIM public key record
dig _dmarc.example.com TXT +short
DMARC policy record
dig _mta-sts.example.com TXT +short
MTA-STS policy record
dig _smtp._tls.example.com TXT +short
SMTP TLS Reporting (TLSRPT)
dig _25._tcp.mail.example.com TLSA
DANE TLSA record for SMTP

Batch & Scripting

dig
Useful patterns for automation and scripts
dig +short +identify example.com A
Show which server replied
dig +noall +answer +ttlid example.com A
Show remaining TTL
dig +norec @ns1.example.com example.com A
Non-recursive (auth only)
dig -f domains.txt +short A
Batch lookup from file
dig example.com A example.com MX example.com NS
Multiple queries at once

Anatomy of dig Output — Debugging a DNSSEC Validation Failure

A domain's HTTPS suddenly stops resolving through your recursive resolver — clients get SERVFAIL. You query the authoritative server directly and it works fine. This is the classic symptom of a DNSSEC validation failure. Here is the full dig session that diagnoses it, with every output field explained.

💡
Scenario: dig app.example.com A returns SERVFAIL from your resolver (10.0.1.1), but dig @ns1.example.com app.example.com A returns the correct IP. This means the record exists but something in the validation chain is broken. We run dig +dnssec +multiline to inspect the raw DNSSEC data from the authoritative server.
dig output — full annotated walkthrough $ dig @ns1.example.com app.example.com A +dnssec +multiline
Header Section
; <<>> DiG 9.18.24 <<>> @ns1.example.com app.example.com A +dnssec +multiline ; (1 server found)
1
Version & query echo. dig prints its version and repeats your full command back. (1 server found) means the @ns1.example.com hostname resolved to one IP. If you see (2 servers found), dig will try both (IPv4 and IPv6).
;; global options: +cmd
2
Global options. +cmd means the command header is printed (default on). Other globals like +all or +noall would appear here. This line confirms which output sections are active.
;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 41562 ;; flags: qr aa rd; QUERY: 1, ANSWER: 2, AUTHORITY: 2, ADDITIONAL: 5
3
Response header — the most important block.
opcode: QUERY — standard query (vs. IQUERY, STATUS, NOTIFY, UPDATE).
status: NOERROR — the authoritative server returned success (RCODE 0). Other values: NXDOMAIN (3), SERVFAIL (2), REFUSED (5), FORMERR (1).
id: 41562 — 16-bit transaction ID matching query to response (RFC 1035 §4.1.1). Mismatches indicate spoofed responses.
Flags:
qr = Query Response (this is a response, not a query)
aa = Authoritative Answer — the server is authoritative for this zone. This is key: it proves we're getting data from the source, not a cache.
rd = Recursion Desired — we asked for recursion (our side), but there's no ra flag because this authoritative server doesn't offer recursion.
Missing flags to watch for: no ad (Authenticated Data) means DNSSEC was NOT validated by this server. No tc (Truncated) means the response fit in one UDP packet.
Section counts: 1 question, 2 answers (A + RRSIG), 2 authority (NS records), 5 additional (glue A/AAAA + OPT).
OPT Pseudosection (EDNS)
;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags: do; udp: 1232
4
EDNS0 (RFC 6891) metadata.
version: 0 — EDNS version (always 0 currently).
flags: doDNSSEC OK bit is set. This means we asked the server to include DNSSEC records (RRSIG, NSEC, etc.) in its response. Set by our +dnssec flag.
udp: 1232 — the server's advertised UDP payload size. 1232 bytes is the current recommended maximum (RFC 8085, DNS Flag Day 2020) to avoid IP fragmentation. If the response exceeds this, the server sets the tc (truncated) flag and the client retries over TCP.
Question Section
;; QUESTION SECTION: ;app.example.com. IN A
5
The question we asked. Echoed back verbatim. Format: QNAME QCLASS QTYPE. Note the trailing dot — this is the FQDN. IN = Internet class (virtually always). A = IPv4 address record. If this doesn't match your query, something intercepted or rewrote it.
Answer Section — The Records
app.example.com. 300 IN A 203.0.113.50
6
The A record itself. Format: NAME TTL CLASS TYPE RDATA.
300 = TTL in seconds (5 minutes). This is the remaining TTL at query time — it counts down from the zone's configured value. If you query your caching resolver, this number decreases on each query until the record expires and is re-fetched.
203.0.113.50 = the IPv4 address (RDATA). This is the actual answer.
app.example.com. 300 IN RRSIG A 13 3 300 ( 20250315120000 20250213120000 12345 example.com. oG7Tz+kPVmRqSE1J5xkN3ZcYg... )
7
RRSIG — the DNSSEC signature over the A record. This is where the bug is. Field by field:
A — type covered (this signature signs the A RRset).
13 — algorithm: ECDSAP256SHA256 (modern, good). Common values: 8=RSA/SHA-256, 13=ECDSA/P-256, 15=Ed25519.
3 — labels: number of labels in the owner name (app.example.com = 3). Used to detect wildcard expansion (if actual labels > this count, it was a wildcard match).
300 — original TTL the zone was signed with.
20250315120000signature expiration (March 15, 2025 12:00 UTC).
20250213120000 — signature inception (Feb 13, 2025).
12345key tag identifying which DNSKEY signed this. A resolver uses this to find the matching public key.
example.com. — signer's name (the zone that holds the DNSKEY).
The base64 blob is the actual cryptographic signature.
Authority Section
example.com. 3600 IN NS ns1.example.com. example.com. 3600 IN NS ns2.example.com.
8
Authority section. Lists the NS records for the zone. Included because the server is authoritative (aa flag). If querying a recursive resolver and the answer came from cache, this section would typically be empty. The 3600s TTL (1 hour) controls how long resolvers cache the delegation.
Additional Section
ns1.example.com. 3600 IN A 93.184.216.1 ns1.example.com. 3600 IN AAAA 2001:db8::1 ns2.example.com. 3600 IN A 93.184.216.2 ns2.example.com. 3600 IN AAAA 2001:db8::2
9
Glue records. The IP addresses of the name servers listed in the authority section. These are "additional" data provided proactively so the resolver doesn't need a separate lookup to reach the NS servers. Critical for in-bailiwick name servers (ns1.example.com within example.com) — without glue, there's a chicken-and-egg problem.
Footer — Stats
;; Query time: 24 msec ;; SERVER: 93.184.216.1#53(ns1.example.com) (UDP) ;; WHEN: Thu Feb 13 14:32:07 UTC 2025 ;; MSG SIZE rcvd: 478
10
Query metadata.
Query time: 24 msec — round-trip time to the server. >100ms suggests network issues or geographic distance. 0ms means it came from local cache.
SERVER: 93.184.216.1#53 — IP and port of the server that replied. (ns1.example.com) is the name we queried. (UDP) confirms the transport protocol used.
MSG SIZE rcvd: 478 — response size in bytes. If this exceeds the EDNS UDP buffer (1232), the response would be truncated and retried over TCP. Responses >512 bytes require EDNS0 support.

The Diagnosis

The authoritative server returns NOERROR with a valid A record. So the data is fine. The problem is in the RRSIG at marker 7 above. Let's investigate the key tag and check the matching DNSKEY:

dig output — checking the DNSKEY $ dig @ns1.example.com example.com DNSKEY +multiline +dnssec
example.com. 3600 IN DNSKEY 256 3 13 ( k7Lz8vNpQ2mH9xYrT... ) ; ZSK ; alg = ECDSAP256SHA256 ; key id = 67890
!
Key tag mismatch found. The RRSIG references key tag 12345, but the only ZSK published in the zone has key tag 67890. This means a ZSK rollover happened — the zone was re-signed with a new key, but the old DNSKEY (12345) was already removed from the zone before the old RRSIG expired.

DNSKEY flags field:
256 = Zone Signing Key (ZSK). Bit 7 set (Zone Key) + bit 15 clear.
257 = Key Signing Key (KSK). Bit 7 set + bit 15 set (Secure Entry Point).
3 = protocol (always 3 for DNSSEC, per RFC 4034 §2.1.2).
13 = algorithm number (same as the RRSIG).
example.com. 3600 IN DNSKEY 257 3 13 ( r9Xk2wPqJ4nF7aYsU... ) ; KSK ; alg = ECDSAP256SHA256 ; key id = 11111
KSK is fine. The Key Signing Key (flag 257) is present and its key tag (11111) matches the DS record in the parent zone. The chain of trust from the root through .com to example.com is intact. Only the ZSK link is broken.
🚨
Root cause: During a ZSK rollover, the old DNSKEY (tag 12345) was removed from the zone before all RRSIGs signed by it had expired. The RRSIG over app.example.com A still references key 12345, but resolvers can no longer find that key in the DNSKEY RRset — so signature verification fails and they return SERVFAIL.

Fix: Re-sign the zone with the current ZSK (67890): run rndc sign example.com or wait for inline-signing to catch up. To prevent this in the future, always follow the pre-publish or double-signature rollover method (RFC 6781 §4.1) — keep the old DNSKEY published until all its RRSIGs have expired.
🔍
Quick verification commands for this scenario:
dig +cd @10.0.1.1 app.example.com A — bypasses DNSSEC validation on your resolver. If this returns NOERROR while the normal query returns SERVFAIL, the problem is definitively DNSSEC.
delv @ns1.example.com app.example.com A +vtrace — walks the full chain of trust and reports exactly where validation fails.
dig example.com DNSKEY +short — list all published keys to compare against RRSIG key tags.

nslookup — Legacy Interactive Tool

Available on virtually all operating systems including Windows. Supports both interactive and non-interactive modes. While considered deprecated on Unix, it remains the go-to tool on Windows systems.

Non-Interactive Mode

nslookup
One-shot queries from the command line
nslookup example.com
Default A record query
nslookup example.com 8.8.8.8
Query specific DNS server
nslookup -type=MX example.com
Query MX records
nslookup -type=NS example.com
Query name servers
nslookup -type=TXT example.com
Query TXT records
nslookup -type=SOA example.com
Query SOA record
nslookup -type=PTR 34.216.184.93.in-addr.arpa
Reverse DNS lookup
nslookup -type=AAAA example.com
IPv6 address lookup
nslookup -type=ANY example.com
All record types
nslookup -debug example.com
Verbose debug output
nslookup -type=SRV _sip._tcp.example.com
Service record query

Windows-Specific

nslookup
Windows nslookup and related commands
nslookup -type=MX example.com 8.8.8.8
MX via specific server
ipconfig /displaydns
Show Windows DNS cache
ipconfig /flushdns
Flush Windows DNS cache
Resolve-DnsName example.com -Type A
PowerShell DNS query
Resolve-DnsName example.com -Type MX -Server 8.8.8.8
PowerShell MX via server

host — Simple DNS Lookup

A streamlined utility for quick DNS lookups with clean, human-readable output. Ideal for shell scripts and fast checks. Part of the BIND utilities package.

host Commands

host
Quick and clean DNS queries
host example.com
A + AAAA + MX lookup
host -t A example.com
A record only
host -t MX example.com
Mail server records
host -t NS example.com
Name server records
host -t TXT example.com
Text records
host -t SOA example.com
SOA record
host 93.184.216.34
Reverse lookup (auto-detects IP)
host -a example.com
Verbose — all info (like dig)
host -v example.com
Verbose output with headers
host example.com 8.8.8.8
Use specific resolver
host -l example.com ns1.example.com
List zone (zone transfer)
host -W 5 example.com
Set 5-second timeout

Other DNS Tools

Specialized tools for DNSSEC validation, modern output, and network diagnostics.

delv — DNSSEC Validation

delv
BIND's dedicated DNSSEC validation utility. Shows the full chain of trust and validation status. Replaces dig +sigchase.
delv example.com A
Validated A record lookup
delv @8.8.8.8 example.com A
Validate via specific server
delv +vtrace example.com A
Verbose validation trace
delv +rtrace example.com A
Show resolver-style trace
delv +mtrace example.com A
Show all trust chain details
delv +noroot example.com DNSKEY
Skip trust anchor lookup

drill — LDNS-based Lookup

drill
Part of the ldns library (NLnet Labs). Similar to dig but with better DNSSEC chain validation. Common on BSDs. Install: apt install ldnsutils.
drill example.com
Basic A record lookup
drill -T example.com
Trace from root
drill -S example.com
Chase DNSSEC signatures
drill -DT example.com
Trace with DNSSEC
drill -V 5 example.com
Maximum verbosity level
drill example.com @8.8.8.8 MX
MX via specific server

kdig — Knot DNS Lookup

kdig
Part of Knot DNS utilities. Advanced features including native DoT and DoH support. Install: apt install knot-dnsutils.
kdig example.com A
Basic lookup
kdig +tls @1.1.1.1 example.com A
DNS over TLS query
kdig +https @1.1.1.1 example.com A
DNS over HTTPS query
kdig +quic @dns.adguard.com example.com
DNS over QUIC query
kdig -x 93.184.216.34
Reverse DNS lookup

Network & OS Diagnostics

system
OS-level DNS configuration, caching, and connectivity checks
cat /etc/resolv.conf
View resolver config (Linux)
resolvectl status
systemd-resolved status
resolvectl query example.com
Query via systemd-resolved
resolvectl flush-caches
Flush systemd DNS cache
resolvectl statistics
Cache hit/miss statistics
sudo dscacheutil -flushcache
Flush macOS DNS cache
sudo killall -HUP mDNSResponder
Restart macOS DNS resolver
scutil --dns
macOS DNS config details
getent hosts example.com
Query NSS (hosts + DNS)
ss -ulnp | grep :53
Check what listens on port 53
tcpdump -i eth0 port 53 -nn
Capture DNS traffic live

BIND Server Management

Commands for managing BIND named daemon, validating configurations, and controlling the server.

rndc — Remote Control

rndc
Control the running BIND daemon without restarting
rndc status
Server status & version
rndc reload
Reload all zones & config
rndc reload example.com
Reload specific zone
rndc reconfig
Reload config only (new zones)
rndc flush
Flush entire cache
rndc flushname example.com
Flush one name from cache
rndc flushtree example.com
Flush name + subdomains
rndc querylog on
Enable query logging
rndc querylog off
Disable query logging
rndc dumpdb -all
Dump cache to file
rndc stats
Write statistics to file
rndc retransfer example.com
Force zone transfer (secondary)
rndc notify example.com
Send NOTIFY to secondaries
rndc signing -list example.com
List DNSSEC signing keys
rndc zonestatus example.com
Detailed zone status
rndc recursing
Dump recursive queries list
rndc trace 3
Set debug level to 3
rndc notrace
Disable debug logging

Config & Zone Validation

named-check*
Always validate before reloading — catch errors before they cause outages
named-checkconf /etc/named/named.conf
Validate named.conf syntax
named-checkconf -z /etc/named/named.conf
Check config + all zones
named-checkconf -p /etc/named/named.conf
Print parsed config (canonical)
named-checkzone example.com /var/named/zones/db.example.com
Validate zone file
named-checkzone -k fail example.com db.example.com
Strict checking mode
named-checkzone 1.0.10.in-addr.arpa /var/named/zones/db.10.0.1
Check reverse zone
named-compilezone -o - example.com db.example.com
Output compiled zone to stdout
rndc-confgen -a
Generate rndc.key file
tsig-keygen -a hmac-sha256 transfer-key
Generate TSIG key
journalctl -u named -f
Follow BIND logs (systemd)
named -V
BIND version & build options

Common Issues & Solutions

SERVFAIL Responses

  • DNSSEC validation failure — check signatures and key rollover status
  • Authoritative server unreachable — verify NS records and network connectivity
  • Broken delegation — parent NS records don't match child zone's NS records
  • Use dig +cd to bypass DNSSEC validation for diagnosis
  • Check delv +vtrace for detailed DNSSEC chain validation

NXDOMAIN When Record Exists

  • Stale negative cache — wait for negative TTL or run rndc flush
  • Wrong zone file loaded — validate with named-checkzone
  • Serial number not incremented — secondaries won't transfer changes
  • Missing trailing dot on FQDN in zone file (relative vs absolute name)
  • Check $ORIGIN directive — unqualified names get it appended

🐢 Slow Resolution

  • Timeout waiting for unresponsive forwarder — consider removing it
  • IPv6 attempted but not routable — disable AAAA queries or fix IPv6 routing
  • Large cache miss rate — increase max-cache-size in options
  • Enable prefetch to proactively refresh popular records
  • Use dig +stats to check query time from different servers

🚫 Zone Transfer Failures

  • TSIG key mismatch — verify key name, algorithm, and secret match on both
  • Firewall blocking TCP/53 — AXFR/IXFR require TCP
  • Serial number issue — primary must have higher serial than secondary
  • Check allow-transfer ACLs on primary — must list secondary IP or key
  • Use rndc retransfer to force-retry, check logs with journalctl -u named
🔧
Pro Tip: When debugging DNS, always compare results from multiple resolvers. Query your local resolver, then an authoritative server directly (dig @ns1.example.com), then a public resolver (dig @8.8.8.8). Differences between them reveal where the problem lies — caching, delegation, or the zone data itself.

13 — RFC Reference

The standards that define DNS

Core DNS Standards

RFC 1034
Domain Names — Concepts and Facilities
The foundational RFC describing the DNS architecture, name space, and resolution algorithm. Defines domains, zones, delegation, and caching concepts. Published November 1987. (Obsoletes RFC 882, 883, 973)
Read RFC 1034
RFC 1035
Domain Names — Implementation and Specification
Companion to RFC 1034. Specifies the DNS wire protocol, message format, transport (UDP/TCP on port 53), master file format, and the original resource record types (A, NS, CNAME, SOA, MX, PTR, TXT).
Read RFC 1035
RFC 2181
Clarifications to the DNS Specification
Resolves ambiguities in RFC 1034/1035. Clarifies RRset rules, TTL handling, credibility ranking, zone authority, and the behavior of CNAME records.
Read RFC 2181
RFC 1995
Incremental Zone Transfer in DNS (IXFR)
Defines incremental zone transfers, allowing secondary servers to request only the changes since a given serial number, rather than the entire zone.
Read RFC 1995
RFC 1996
A Mechanism for Prompt Notification of Zone Changes (DNS NOTIFY)
Allows primary servers to proactively notify secondary servers when a zone has been updated, triggering immediate zone transfers rather than waiting for the SOA refresh interval.
Read RFC 1996
RFC 2136
Dynamic Updates in the DNS (UPDATE)
Specifies a mechanism for adding, deleting, and modifying DNS records dynamically without editing zone files. Essential for DHCP integration and automated provisioning.
Read RFC 2136

DNSSEC Standards

RFC 4033
DNS Security Introduction and Requirements
Overview of DNSSEC, threat model, and the security services it provides: origin authentication and data integrity.
Read RFC 4033
RFC 4034
Resource Records for DNSSEC
Defines DNSKEY, RRSIG, NSEC, and DS resource record types used by DNSSEC for signing and validation.
Read RFC 4034
RFC 4035
Protocol Modifications for DNSSEC
Specifies the DNS protocol modifications needed to support DNSSEC: how signers create signatures, how validators verify them, and the resolution process changes.
Read RFC 4035
RFC 5155
DNS Security (DNSSEC) Hashed Authenticated Denial of Existence (NSEC3)
Introduces NSEC3 records that use hashed owner names, preventing zone enumeration while still providing authenticated denial of existence.
Read RFC 5155
RFC 6781
DNSSEC Operational Practices, Version 2
Practical guidance on DNSSEC key management, key rollovers (ZSK and KSK), algorithm selection, and operational considerations.
Read RFC 6781
RFC 8198
Aggressive Use of DNSSEC-Validated Cache
Allows resolvers to synthesize NXDOMAIN responses from cached NSEC/NSEC3 records, reducing query load on authoritative servers.
Read RFC 8198

Modern DNS & Extensions

RFC 6891
Extension Mechanisms for DNS (EDNS0)
Extends the DNS protocol beyond the original 512-byte UDP limit (up to 4096 bytes) and adds support for new flags and options. Essential for DNSSEC.
Read RFC 6891
RFC 7858
Specification for DNS over TLS (DoT)
Encrypts DNS traffic using TLS on port 853. Provides confidentiality for DNS queries between stub resolvers and recursive resolvers.
Read RFC 7858
RFC 8484
DNS Queries over HTTPS (DoH)
Specifies how to send DNS queries and receive responses over HTTPS using standard HTTP methods. Provides both confidentiality and resistance to network-level DNS filtering.
Read RFC 8484
RFC 9250
DNS over Dedicated QUIC Connections (DoQ)
DNS transport over QUIC, combining the privacy of encrypted DNS with QUIC's performance benefits: 0-RTT connection resumption, stream multiplexing, and lower latency.
Read RFC 9250
RFC 9230
Oblivious DNS over HTTPS (ODoH)
Adds a proxy between client and resolver to ensure the resolver never learns the client's IP and the proxy never learns the query content.
Read RFC 9230
RFC 8767
Serving Stale Data to Improve DNS Resiliency
Allows recursive resolvers to serve expired cached records when authoritative servers are unreachable, improving resilience.
Read RFC 8767
RFC 5936
DNS Zone Transfer Protocol (AXFR)
Updates the original AXFR mechanism from RFC 1035 with a clearer, more robust specification for full zone transfers over TCP.
Read RFC 5936
RFC 2845
Secret Key Transaction Authentication for DNS (TSIG)
Defines TSIG, a mechanism for authenticating DNS messages (especially zone transfers and dynamic updates) using shared secret keys and HMAC signatures.
Read RFC 2845
RFC 9432
DNS Catalog Zones
Defines catalog zones for automated provisioning of DNS zones on secondary name servers using a specially formatted DNS zone.
Read RFC 9432
RFC 9460
Service Binding and Parameter Specification via the DNS (SVCB and HTTPS)
Defines SVCB and HTTPS record types for advertising service parameters (ALPN, ECH, port, IP hints) directly in DNS, enabling faster connection setup.
Read RFC 9460
RFC 8659
DNS Certification Authority Authorization (CAA)
Allows domain owners to specify which CAs are permitted to issue certificates for their domain, reducing the risk of mis-issuance.
Read RFC 8659
RFC 7871
Client Subnet in DNS Queries (ECS)
Allows recursive resolvers to forward partial client subnet information to authoritative servers, enabling geographically optimized responses from CDNs.
Read RFC 7871
📚
Further Reading: The complete list of DNS-related RFCs is maintained by IANA. Key resources include the ISC BIND documentation, the IANA Root Zone Database, and the DNS-OARC community for operational best practices.