Loading content...
While DNS was originally designed for name-to-address resolution, its globally distributed, highly available, and cacheable infrastructure proved too valuable to limit to just IP addresses. Over the decades, DNS has evolved into a general-purpose data distribution system, serving verification tokens, security policies, service discovery, and arbitrary metadata.
The TXT record (Text record) is the most flexible of these extended record types—a simple container for human-readable text that has been repurposed for machine-readable data including SPF, DKIM, DMARC, domain verification, and more. Beyond TXT records, DNS hosts specialized record types for service location (SRV), certificate authority authorization (CAA), reverse lookups (PTR), and zone metadata (SOA).
This page provides exhaustive coverage of TXT records and other important DNS record types, exploring their structure, common use cases, security implications, and operational best practices.
By the end of this page, you will understand: (1) TXT record structure and its role in email authentication (SPF, DKIM, DMARC), (2) Domain verification patterns, (3) SRV records for service discovery, (4) CAA records for certificate issuance control, (5) PTR records for reverse DNS, (6) SOA records for zone metadata, and (7) Emerging record types and their applications.
The TXT record (Text record) is defined in RFC 1035 as a container for arbitrary text data. Originally intended for human-readable notes about a domain, TXT records have evolved into critical infrastructure for authentication and verification.
A TXT record associates:
The abstract representation:
<domain> IN TXT "<text-string>"
For example:
example.com. 300 IN TXT "v=spf1 include:_spf.google.com ~all"
| Field | Size | Description |
|---|---|---|
| NAME | Variable | Domain name |
| TYPE | 2 bytes | Record type = 16 (TXT) |
| CLASS | 2 bytes | Class = 1 (IN) |
| TTL | 4 bytes | Time-to-live |
| RDLENGTH | 2 bytes | Length of RDATA |
| RDATA | Variable | One or more character-strings |
Character-string format: Each string in RDATA is length-prefixed:
A TXT record can contain multiple character-strings, concatenated upon retrieval.
Each individual character-string in a TXT record is limited to 255 bytes (due to the 1-byte length prefix). This creates complications for longer values like DKIM keys.
Solution: Use multiple strings that are concatenated:
example.com. 300 IN TXT "v=DKIM1; k=rsa; p=MIIBIjANBg..." "...additional characters..."
Resolvers and applications concatenate these strings into a single value.
In BIND zone file format, special characters in TXT records must be escaped: quotes as " and backslashes as \. Most DNS providers' web interfaces handle escaping automatically, but when editing zone files directly, be careful with special characters.
The most critical use of TXT records in modern infrastructure is email authentication. Three technologies—SPF, DKIM, and DMARC—use DNS TXT records to combat email spoofing and phishing.
SPF (RFC 7208) allows domain owners to declare which mail servers are authorized to send email for their domain.
Location: TXT record at domain apex
Format:
example.com. 300 IN TXT "v=spf1 <mechanisms> <qualifier>"
Example with explanation:
example.com. 300 IN TXT "v=spf1 ip4:192.0.2.0/24 include:_spf.google.com mx -all"
| Mechanism | Meaning |
|---|---|
v=spf1 | SPF version 1 |
ip4:192.0.2.0/24 | Allow IPs in this range |
include:_spf.google.com | Include Google Workspace's SPF |
mx | Allow IPs of domain's MX servers |
-all | Reject all other senders (hard fail) |
Qualifiers:
+ (pass, default)- (hard fail)~ (soft fail)? (neutral)DKIM (RFC 6376) adds a cryptographic signature to emails, proving they came from an authorized sender.
Location: TXT record at <selector>._domainkey.<domain>
Format:
selector1._domainkey.example.com. 300 IN TXT "v=DKIM1; k=rsa; p=MIIBIj..."
| Tag | Meaning |
|---|---|
v=DKIM1 | DKIM version |
k=rsa | Key type (rsa or ed25519) |
p=... | Base64-encoded public key |
t=s (optional) | Strict alignment required |
t=y (optional) | Testing mode |
How DKIM Works:
DMARC (RFC 7489) builds on SPF and DKIM, specifying what to do when they fail and enabling reporting.
Location: TXT record at _dmarc.<domain>
Format:
_dmarc.example.com. 300 IN TXT "v=DMARC1; p=reject; rua=mailto:dmarc@example.com"
| Tag | Meaning |
|---|---|
v=DMARC1 | DMARC version |
p=reject | Policy: reject, quarantine, or none |
rua= | Aggregate report destination |
ruf= | Forensic report destination |
pct=100 | Percentage of messages to apply policy |
adkim=s | DKIM alignment: strict or relaxed |
aspf=s | SPF alignment: strict or relaxed |
| Technology | Record Location | What It Validates | Signature |
|---|---|---|---|
| SPF | domain TXT | Sending IP is authorized | None (IP-based) |
| DKIM | selector._domainkey.domain TXT | Email content integrity | RSA/Ed25519 |
| DMARC | _dmarc.domain TXT | Policy + SPF/DKIM alignment | Policy only |
Unlike CNAME, you can have multiple TXT records at the same domain. However, for SPF, you should have only ONE SPF record (RFC 7208). Multiple SPF records cause evaluation to fail. If you need multiple configurations, use 'include:' mechanisms within a single SPF record.
TXT records serve as a universal mechanism for domain ownership verification. When you sign up for a service that needs to confirm you control a domain, TXT records are typically the verification method.
Pattern 1: Root Domain TXT
example.com. 300 IN TXT "google-site-verification=abc123..."
example.com. 300 IN TXT "ms=ms12345678"
example.com. 300 IN TXT "facebook-domain-verification=xyz789"
Pattern 2: Subdomain TXT
_acme-challenge.example.com. 300 IN TXT "gfj9Xq..." ; Let's Encrypt
_github-challenge-org.example.com. 300 IN TXT "abc123"
_dnslink.example.com. 300 IN TXT "/ipfs/QmX..."
Pattern 3: Labeled TXT (Namespaced)
_atproto.example.com. 300 IN TXT "did:plc:..." ; Bluesky
_mta-sts.example.com. 300 IN TXT "v=STSv1; id=..."
| Service | Record Location | Example Value |
|---|---|---|
| Google Search Console | domain.com TXT | google-site-verification=... |
| Microsoft 365 | domain.com TXT | MS=ms12345678 |
| domain.com TXT | facebook-domain-verification=... | |
| Let's Encrypt | _acme-challenge.domain TXT | (dynamic challenge token) |
| GitHub Pages | _github-challenge-org.domain TXT | organization-specific-token |
| Atlassian | domain.com TXT | atlassian-domain-verification=... |
| Stripe | domain.com TXT | stripe-verification=... |
1. Remove Unneeded Verification Records Old verification TXT records for services you no longer use should be removed. They clutter your zone and could theoretically be exploited if the verification mechanism has weaknesses.
2. Understand What You're Verifying Verification proves domain control to the service. Ensure you trust the service before adding their verification token.
3. Use Short TTL for Temporary Verifications
; Use short TTL for verification, then remove
_acme-challenge.example.com. 60 IN TXT "challenge-token"
After verification succeeds, remove the record.
Let's Encrypt and other CAs use the DNS-01 challenge for domain validation:
_acme-challenge.domain.com TXT "<token>"Advantages of DNS-01:
Automation: Use tools like certbot with DNS plugins or acme.sh to automate DNS-01 challenges.
SRV records (Service records, RFC 2782) enable DNS-based service discovery. They answer the question: "Where is the server for a particular service on this domain?"
SRV records associate:
_<service>._<protocol>.<domain> TTL IN SRV <priority> <weight> <port> <target>
Example: XMPP (Jabber) SRV records
_xmpp-client._tcp.example.com. 300 IN SRV 10 5 5222 chat.example.com.
_xmpp-server._tcp.example.com. 300 IN SRV 10 5 5269 chat.example.com.
This tells XMPP clients: "To connect to example.com, contact chat.example.com on port 5222."
Example: Microsoft Active Directory
_ldap._tcp.dc._msdcs.corp.example.com. 300 IN SRV 0 100 389 dc1.corp.example.com.
_kerberos._tcp.corp.example.com. 300 IN SRV 0 100 88 dc1.corp.example.com.
| Field | Purpose | Example |
|---|---|---|
| Priority | Order of preference (lower first) | 10, 20, 30 |
| Weight | Load distribution within priority | 60/40 = 60:40 traffic split |
| Port | TCP/UDP port for service | 5222, 443, 389 |
| Target | Server hostname (must have A/AAAA) | chat.example.com. |
When multiple SRV records have the same priority, weight determines load distribution:
_http._tcp.example.com. 300 IN SRV 10 60 80 server1.example.com.
_http._tcp.example.com. 300 IN SRV 10 40 80 server2.example.com.
Clients should direct 60% of requests to server1, 40% to server2.
| Service | SRV Record Name |
|---|---|
| XMPP Client | _xmpp-client._tcp.domain |
| XMPP Server | _xmpp-server._tcp.domain |
| SIP (VoIP) | _sip._tcp.domain or _sip._udp.domain |
| LDAP | _ldap._tcp.domain |
| Kerberos | _kerberos._tcp.domain |
| CalDAV | _caldavs._tcp.domain |
| CardDAV | _carddavs._tcp.domain |
| Matrix | _matrix._tcp.domain |
Notably, HTTP/HTTPS don't traditionally use SRV records. Instead, browsers assume:
RFC 6186 defines SRV for HTTP, but browser adoption is minimal. Modern alternatives include Alt-Svc headers and HTTPS DNS records (covered later).
Per RFC 2782, the SRV target hostname must have A/AAAA records directly—it cannot be a CNAME. This is similar to the MX/CNAME restriction. Additionally, a target of '.' (dot) means the service is explicitly not available.
CAA records (Certification Authority Authorization, RFC 8659) allow domain owners to specify which Certificate Authorities (CAs) are permitted to issue TLS certificates for their domain.
Before CAA, any CA could issue a certificate for any domain (if they could validate domain control). This meant:
CAA empowers domain owners to restrict which CAs can issue certificates, reducing the attack surface.
<domain> TTL IN CAA <flags> <tag> <value>
Tags:
issue: CAs permitted to issue regular certificatesissuewild: CAs permitted to issue wildcard certificatesiodef: URL for incident reportingExamples:
; Only Let's Encrypt can issue for this domain
example.com. 300 IN CAA 0 issue "letsencrypt.org"
; Let's Encrypt for regular, DigiCert for wildcard
example.com. 300 IN CAA 0 issue "letsencrypt.org"
example.com. 300 IN CAA 0 issuewild "digicert.com"
; No wildcards allowed
example.com. 300 IN CAA 0 issuewild ";"
; Report violations via email
example.com. 300 IN CAA 0 iodef "mailto:security@example.com"
www.example.com → no CAAexample.com → CAA found → evaluateThe flags field (0 or 128) controls behavior:
; Unknown critical tag - CA must refuse if it doesn't understand
example.com. 300 IN CAA 128 customtag "value"
CAA records are inherited by subdomains unless overridden:
; Only DigiCert for all of example.com
example.com. 300 IN CAA 0 issue "digicert.com"
; api.example.com allows Let's Encrypt (overrides parent)
api.example.com. 300 IN CAA 0 issue "letsencrypt.org"
The www.example.com subdomain inherits the DigiCert restriction from parent.
CAA is a policy declaration that CAs must respect, but it requires CAs to actually check and comply. If an attacker compromises a CA's issuance systems entirely, they could potentially bypass CAA checks. CAA is one layer of defense, not complete protection. Combine with Certificate Transparency (CT) log monitoring.
PTR records (Pointer records) enable reverse DNS lookups—mapping IP addresses back to hostnames. While A/AAAA records answer "What is the IP for this name?", PTR records answer "What is the name for this IP?"
Reverse DNS uses special domain hierarchies:
IPv4: in-addr.arpa
IP: 192.0.2.1
Reverse domain: 1.2.0.192.in-addr.arpa.
Note: The octets are reversed.
IPv6: ip6.arpa
IP: 2001:db8::1
Full: 2001:0db8:0000:0000:0000:0000:0000:0001
Reverse: 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.
Each hex digit becomes a label, reversed.
1.2.0.192.in-addr.arpa. 3600 IN PTR mail.example.com.
This declares: "The IP 192.0.2.1 has hostname mail.example.com."
PTR records are managed by whoever controls the IP address space, typically:
You typically request PTR record creation from your IP provider, rather than managing them yourself.
1. Email Deliverability
Many mail servers verify that the sending IP has a valid PTR record that matches the SMTP HELO/EHLO hostname. Missing or mismatched PTR often causes email rejection:
; Forward lookup
mail.example.com. A 192.0.2.1
; Reverse lookup (should match)
1.2.0.192.in-addr.arpa. PTR mail.example.com.
2. Logging and Diagnostics
Network administrators prefer hostnames in logs:
192.0.2.50 → webserver.example.com (more readable)
3. Access Control
Some services restrict access based on reverse DNS patterns:
# Apache configuration
Require host .example.com
4. Anti-Spam Heuristics
Lack of PTR record is a spam indicator. Generic PTR (like 192-0-2-1.generic.isp.com) is less trusted than dedicated PTR.
FCrDNS (Forward-Confirmed reverse DNS) requires:
Both directions must match for the strongest verification:
192.0.2.1 → PTR → mail.example.com
mail.example.com → A → 192.0.2.1 ✓
If the forward lookup returns a different IP, FCrDNS fails.
Use dig for reverse lookups:
dig -x 192.0.2.1 (shorthand)
dig PTR 1.2.0.192.in-addr.arpa. (explicit)
For IPv6:
dig -x 2001:db8::1
The SOA record (Start of Authority) contains essential metadata about a DNS zone. Every zone must have exactly one SOA record at its apex.
example.com. 3600 IN SOA ns1.example.com. hostmaster.example.com. (
2024011701 ; Serial
7200 ; Refresh
3600 ; Retry
1209600 ; Expire
3600 ; Minimum TTL (negative caching)
)
| Field | Example | Purpose |
|---|---|---|
| Primary NS | ns1.example.com. | Primary/master nameserver |
| hostmaster.example.com. | Admin email (@ → .) | |
| Serial | 2024011701 | Zone version (must increment on change) |
| Refresh | 7200 (2h) | Secondary checks for updates |
| Retry | 3600 (1h) | Retry interval if refresh fails |
| Expire | 1209600 (14d) | Secondary stops serving if master unreachable |
| Minimum | 3600 (1h) | Negative response (NXDOMAIN) TTL |
Date-based (recommended):
YYYYMMDDnn
2024011701 → January 17, 2024, revision 01
Sequential:
1, 2, 3, 4...
Critical Rule: Serial must always increment when zone changes. If serial goes backward, secondaries may not update.
The SOA minimum field determines how long NXDOMAIN (non-existent domain) responses are cached:
Query: nonexistent.example.com
Response: NXDOMAIN, SOA in authority section
Negative cache TTL: min(query TTL, SOA minimum)
This prevents repeated queries for non-existent names.
AXFR (full zone transfer) and IXFR (incremental zone transfer) use SOA:
1. Use Realistic Timers
2. Always Update Serial Forgetting to increment serial is a common cause of secondary servers serving stale data.
3. Use Meaningful Email Address The email in SOA should be monitored. DNS issues are often reported there.
4. Consider Dynamic DNS For zones updated programmatically (e.g., via API), serial is often Unix timestamp:
Serial: 1705487700 ; Unix timestamp
Serial numbers are 32-bit unsigned integers (max ~4.3 billion). If you use Unix timestamps, this is sufficient until year 2106. Date-based serials (YYYYMMDDNN) are human-readable but limit to 99 changes per day. Choose a convention and stick with it.
DNS continues evolving with new record types addressing modern infrastructure needs.
HTTPS records provide rich service binding for HTTPS connections:
example.com. 300 IN HTTPS 1 . alpn="h2,h3" ipv4hint="192.0.2.1" ipv6hint="2001:db8::1"
Benefits:
SVCB (Service Binding) is the general form; HTTPS is the HTTPS-specific alias.
TLSA records bind TLS certificates to domain names via DNS:
_443._tcp.www.example.com. 300 IN TLSA 3 1 1 abc123...
With DNSSEC, this provides CA-independent certificate validation.
DNSKEY: Public keys for zone signing
example.com. 3600 IN DNSKEY 257 3 13 (base64-public-key)
DS: Delegation signer linking child zone's key to parent
example.com. 3600 IN DS 12345 13 2 (hash-of-child-DNSKEY)
| Type | Number | Purpose | RFC |
|---|---|---|---|
| A | 1 | IPv4 address | 1035 |
| AAAA | 28 | IPv6 address | 3596 |
| CNAME | 5 | Canonical name (alias) | 1035 |
| MX | 15 | Mail exchanger | 1035 |
| NS | 2 | Nameserver | 1035 |
| TXT | 16 | Text/verification data | 1035 |
| SRV | 33 | Service location | 2782 |
| CAA | 257 | CA authorization | 8659 |
| PTR | 12 | Pointer (reverse DNS) | 1035 |
| SOA | 6 | Start of authority | 1035 |
| HTTPS | 65 | HTTPS service binding | 9460 |
| SVCB | 64 | General service binding | 9460 |
| TLSA | 52 | TLS certificate association | 6698 |
| DNSKEY | 48 | DNSSEC public key | 4034 |
| DS | 43 | Delegation signer | 4034 |
| RRSIG | 46 | DNSSEC signature | 4034 |
| NSEC | 47 | Next secure record | 4034 |
| NSEC3 | 50 | NSEC with hashing | 5155 |
Use dig to query any record type:
dig <domain> <type>
Examples:
dig example.com HTTPS
dig example.com CAA
dig _dmarc.example.com TXT
dig -x 192.0.2.1
We've conducted a comprehensive exploration of TXT records and specialized DNS record types that extend DNS beyond simple address resolution. Let's consolidate the essential knowledge:
You now possess Principal Engineer-level understanding of DNS records—from foundational A/AAAA and MX records through CNAME aliasing and NS delegation to TXT-based authentication and modern extensions. This comprehensive knowledge equips you to design, troubleshoot, and secure DNS infrastructure at any scale.