DNS Record Types
| Type | Purpose | Example |
|---|---|---|
| A | Domain → IPv4 | example.com → 1.2.3.4 |
| AAAA | Domain → IPv6 | example.com → 2001:db8::1 |
| CNAME | Domain → domain | www → example.com |
| MX | Mail server | @ → mail.example.com (priority 10) |
| TXT | Text (SPF, DKIM, etc.) | "v=spf1 include:sendgrid.net ~all" |
| NS | Name server | @ → ns1.cloudflare.com |
| CAA | CAs allowed to issue certificates | @ → 0 issue "letsencrypt.org" |
Example Record Configurations
CODE
; A record
example.com. 300 IN A 1.2.3.4
www.example.com. 300 IN A 1.2.3.4
; CNAME
www.example.com. 300 IN CNAME example.com.
; MX (when using Gmail)
example.com. 300 IN MX 1 aspmx.l.google.com.
example.com. 300 IN MX 5 alt1.aspmx.l.google.com.
; SPF (anti-spam)
example.com. 300 IN TXT "v=spf1 include:_spf.google.com ~all"
; DMARC
_dmarc.example.com. 300 IN TXT "v=DMARC1; p=quarantine; rua=mailto:dmarc@example.com"Querying DNS with dig
Bash
# Query A record
dig example.com A
# Short output
dig example.com +short
# Query a specific DNS server (bypass cache)
dig @8.8.8.8 example.com A
# MX record
dig example.com MX
# TXT record (check SPF/DKIM)
dig example.com TXT
# Query NS
dig example.com NS
# Trace the full DNS resolution path
dig +trace example.comDNS Troubleshooting Patterns
Bash
# 1. Confirm the domain points to the correct IP
dig +short example.com A
# 2. Query a specific name server directly before propagation
dig @ns1.your-registrar.com example.com A
# 3. Reverse DNS lookup (IP → domain)
dig -x 1.2.3.4
# 4. Check cache TTL via the SOA record
dig example.com SOA
# 5. DNSSEC validation
dig example.com +dnssecTTL Strategy
- Before a change: Lower TTL to 300 seconds (5 minutes). You can roll back quickly if something goes wrong.
- After things stabilize: Raise TTL to 3600–86400 seconds to speed up DNS responses.
- When using a CDN: Cloudflare proxied records have TTL managed automatically.
Editorial note
AI tools may assist drafting. Check the evidence in each guide for whether commands were run and which environment was used. Confirm the current docs for your version before applying instructions, and email us about errors. email us
Questions & answers
Ask a question about this guide. We'll review and reply.