Kahibaro
Discord Login Register

DNS zones and records

Understanding DNS Zones

In the parent DNS chapter you’ve already seen what DNS does and why it matters. Here we focus on how DNS data is organized and expressed: zones and records.

A zone is the part of the DNS namespace that a specific DNS server is authoritative for and is configured to manage. It is not always identical to a domain:

Common patterns:

Zone Files Basics

On traditional nameservers such as BIND, a zone is implemented as a zone file: a text file containing resource records (RRs).

Typical characteristics:

Core syntax elements:

Example (BIND-style forward zone file):

$TTL 3600          ; default TTL 1 hour
$ORIGIN example.com.
@   IN SOA ns1.example.com. admin.example.com. (
        2025121201 ; serial
        3600       ; refresh (1 hour)
        900        ; retry (15 minutes)
        1209600    ; expire (14 days)
        300        ; minimum/negative TTL (5 minutes)
)
    IN NS  ns1.example.com.
    IN NS  ns2.example.com.
ns1 IN A   203.0.113.10
ns2 IN A   203.0.113.11
www IN A   203.0.113.20
api IN A   203.0.113.21
mail IN A  203.0.113.30
    IN MX  10 mail.example.com.

Key Resource Records

A resource record (RR) is a single row in the zone file describing some piece of DNS information.

General record format:

<name> <TTL> <class> <type> <RDATA>

Below are the most important record types for server administration.

SOA (Start of Authority)

Every zone must have exactly one SOA record. It defines the zone’s primary server and zone metadata.

Example:

@ IN SOA ns1.example.com. admin.example.com. (
      2025121201 ; serial
      3600       ; refresh
      900        ; retry
      1209600    ; expire
      300        ; minimum/negative TTL
)

Fields:

NS (Name Server) Records

NS records define which servers are authoritative for a zone.

Example:

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

Meaning:

Delegation is also done with NS records in the parent zone:

sub.example.com. IN NS ns1.sub.example.com.
sub.example.com. IN NS ns2.sub.example.com.

Then, a separate zone is created for sub.example.com.

A and AAAA Records

These map hostnames to IP addresses.

Examples:

www  IN A    203.0.113.20
api  IN A    203.0.113.21
www  IN AAAA 2001:db8:1234::20
api  IN AAAA 2001:db8:1234::21

Notes:

CNAME (Canonical Name) Records

CNAME creates an alias from one name to another hostname.

Example:

www       IN CNAME web01.example.com.
files     IN CNAME storage.example.net.

Rules and caveats:

Typical uses:

MX (Mail Exchanger) Records

MX records specify mail servers for a domain.

Example:

@   IN MX 10 mail1.example.com.
@   IN MX 20 mail2.example.com.

TXT Records

TXT records store arbitrary text. Common uses:

Examples:

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

TXT records are also used for service ownership verification (e.g. DNS-01 challenges, SaaS verification tokens).

SRV Records

SRV records specify the location (host and port) of specific services in a structured way.

Format:

_service._proto.name. TTL IN SRV priority weight port target

Example (for an internal SIP service):

_sip._tcp.example.com. 3600 IN SRV 10 60 5060 sip1.example.com.
_sip._tcp.example.com. 3600 IN SRV 20 20 5060 sip2.example.com.

Fields:

Many modern services (VoIP, some directory services) rely on SRV for auto-discovery.

PTR Records (Reverse DNS)

PTR records implement reverse lookups: IP → hostname. They live in reverse zones (in-addr.arpa for IPv4, ip6.arpa for IPv6).

Example (IPv4):

Zone fragment:

$ORIGIN 113.0.203.in-addr.arpa.
20 IN PTR www.example.com.

Example (IPv6):

Managing reverse zones is often done by the IP owner (ISP or hosting provider). As a server admin, you may have to request PTR changes if you don’t control the reverse zone yourself.

Use cases:

CAA Records

CAA (Certification Authority Authorization) controls which certificate authorities (CAs) may issue TLS certificates for your domain.

Example:

@ IN CAA 0 issue "letsencrypt.org"
@ IN CAA 0 issuewild "letsencrypt.org"
@ IN CAA 0 iodef "mailto:security@example.com"

Fields:

This provides an additional layer of protection against unauthorized certificate issuance.

Wildcard Records

Wildcard records apply to names that do not have explicit records.

Example:

*.example.com. IN A 203.0.113.50

Behavior:

Caveats:

Forward vs Reverse Zones in Practice

Forward Zones

Forward zone covers a domain name and its subdomains, mapping them to IPs and other info.

Typical contents:

Example of a simple forward zone summary:

Reverse Zones

Reverse zones are usually defined per network block.

Contents:

Administrative Best Practices

This chapter’s focus has been the structure and semantics of zones and records. How to configure them in specific DNS server software (such as BIND) is covered in the dedicated “Setting up BIND” and “DNS troubleshooting” chapters.

Views: 24

Comments

Please login to add a comment.

Don't have an account? Register now!