Zone File

Protocols & Standards
A text file that contains all the DNS records for a domain.
← Back to Glossary

What is a Zone File?

A Zone File is a plain text file stored on authoritative nameservers that contains the complete DNS configuration for a domain, including all resource records that define how the domain's DNS queries should be resolved.

Zone File Structure

; Zone file for example.com

$TTL 86400 ; Default TTL (24 hours)

$ORIGIN example.com.

; SOA Record (Start of Authority)

@ IN SOA ns1.example.com. admin.example.com. (

2024010101 ; Serial number (YYYYMMDDNN)

3600 ; Refresh (1 hour)

900 ; Retry (15 minutes)

604800 ; Expire (1 week)

86400 ; Minimum TTL (24 hours)

)

; Nameserver Records

@ IN NS ns1.example.com.

@ IN NS ns2.example.com.

; A Records (IPv4)

@ IN A 192.0.2.1

www IN A 192.0.2.1

mail IN A 192.0.2.10

; AAAA Records (IPv6)

@ IN AAAA 2001:db8::1

; MX Records (Mail)

@ IN MX 10 mail.example.com.

@ IN MX 20 backup-mail.example.com.

; CNAME Records (Aliases)

blog IN CNAME www.example.com.

; TXT Records

@ IN TXT "v=spf1 mx -all"

Common Record Types

RecordPurposeExample Value
SOAZone authority and timingSerial, refresh, retry values
NSNameserver delegationns1.example.com.
AIPv4 address mapping192.0.2.1
AAAAIPv6 address mapping2001:db8::1
MXMail server routing10 mail.example.com.
CNAMEDomain aliasingwww.example.com.
TXTText data (SPF, DKIM, etc.)"v=spf1 mx -all"
SRVService location_sip._tcp.example.com.

Zone File Directives

DirectivePurposeExample
$TTLDefault time-to-live$TTL 86400
$ORIGINBase domain for relative names$ORIGIN example.com.
@Shorthand for $ORIGIN domain@ IN A 192.0.2.1

Best Practices

1. Increment serial: Update serial number with every change for proper zone transfers

2. Use FQDN: End fully qualified domain names with a trailing dot

3. Set appropriate TTLs: Lower for frequently changing records, higher for stable ones

4. Document changes: Add comments with semicolons for record purposes

5. Validate syntax: Use named-checkzone or similar tools before deploying

Zone Transfer Security

Zone transfers (AXFR) replicate zone files between primary and secondary nameservers. Restrict transfers to authorized IPs to prevent information disclosure.

Zone files form the foundation of DNS configuration, defining how domain names resolve to IP addresses and services.

Put This Knowledge to Work

Use DomScan's API to check domain availability, health, and more.