Cloudflare DNS Dashboard Guide for Implementing Secure TXT Records
Setting up Cloudflare DNS TXT records correctly is essential for domain ownership verification, email authentication protocols like SPF, DKIM, and DMARC, and various security services. This comprehensive guide walks you through navigating the Cloudflare dashboard, formatting various types of TXT records, and troubleshooting common validation failures. By the end of this tutorial, you will have the confidence to manage your DNS records securely and efficiently.
Before you make any updates to your production domain, it is best practice to run a diagnostic using the Email Security Checker to identify existing gaps in your domain's authentication posture and verify your changes afterward.
Understanding Cloudflare DNS TXT Records
A TXT (Text) record is a type of resource record in the Domain Name System that allows domain administrators to insert arbitrary text into the DNS. While originally used for human-readable notes, TXT records are now heavily utilized for machine-readable data, primarily security policies.
Cloudflare handles DNS management through a streamlined web interface and a robust API. When managing TXT records in Cloudflare, understanding record length limitations, encoding rules, and proxy status is critical to ensuring your configurations function properly across the global internet.
Key Characteristics of TXT Records
- No Traffic Routing: Unlike A or CNAME records, TXT records do not direct network traffic or point to IP addresses like
192.0.2.1. - Multiple Strings: Standard DNS allows a TXT record to contain multiple character strings, which Cloudflare stitches together or splits depending on total length.
- No Orange Cloud (Proxy): TXT records in Cloudflare are strictly DNS-only. You cannot proxy TXT record lookups through Cloudflare's edge network, meaning the gray cloud icon is always active for these records.
Step-by-Step Cloudflare DNS TXT Records Setup
Follow these sequential steps to add, edit, or remove TXT records within the Cloudflare dashboard.
Step 1: Log in and Navigate to DNS Settings
- Open your web browser and navigate to the Cloudflare dashboard.
- Log in using your credentials and select the target domain (e.g.,
example.com) from your account overview. - In the left-hand sidebar menu, locate and click on DNS, then select Records from the sub-menu.
Step 2: Add a New TXT Record
- Click the blue Add record button located near the top right of the DNS records table.
- From the Type dropdown menu, select TXT.
- In the Name field, enter your desired subdomain or use
@to apply the record to your root domain (example.com). - In the Content field, paste your exact TXT record value, ensuring there are no hidden line breaks or illegal characters.
- Leave the TTL (Time to Live) set to Auto (or choose a specific duration if required by your hosting strategy).
- Click Save to commit the record to your zone.
Type: TXT
Name: @
Content: v=spf1 include:_spf.example.com ~all
TTL: Auto
Configuring Common Security TXT Records
Different security frameworks require precise syntax inside your TXT records. Below are the most common implementations you will manage in the Cloudflare dashboard.
SPF (Sender Policy Framework)
SPF records declare which mail servers are authorized to send email on behalf of your domain. Note that a domain must only have a single SPF record; multiple records will cause validation to fail.
Name: @
Content: v=spf1 ip4:192.0.2.0/24 include:mail.example.com ~all
DKIM (DomainKeys Identified Mail)
DKIM adds a cryptographic signature to your emails. The provider you use for email hosting (such as Google Workspace or Microsoft 365) will supply a specific selector name.
Name: selector1._domainkey
Content: v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQFAAOCAQ8AMIIBCgKCAQEA...
DMARC (Domain-based Message Authentication, Reporting, and Conformance)
DMARC builds upon SPF and DKIM, telling receiving servers how to handle emails that fail authentication checks.
Name: _dmarc
Content: v=DMARC1; p=reject; sp=quarantine; rua=mailto:dmarc-reports@example.com; pct=100
Verification and Troubleshooting
Once you save your TXT records in Cloudflare, changes usually propagate globally within a few seconds due to Cloudflare's high-performance authoritative nameservers. However, local caching by ISPs or recursive resolvers can cause delays.
Using Command Line Tools
You can verify your DNS records directly from your local terminal using standard utilities.
Using dig to query a TXT record:
dig TXT example.com +short
Using nslookup on Windows PowerShell:
Resolve-DnsName -Name example.com -Type TXT
Using curl to check DNS over HTTPS via Cloudflare:
curl -s -H 'Accept: application/dns-json' 'https://cloudflare-dns.com/dns-query?name=example.com&type=TXT' | jq .
Comparison: Cloudflare DNS vs Traditional Registrars
| Feature | Cloudflare DNS | Traditional Registrar DNS |
|---|---|---|
| Propagation Speed | Instantaneous (global edge) | Often 15 minutes to 4 hours |
| API Access | Highly robust REST API | Limited or proprietary |
| Record Limits | Generous limits for all plans | Varies wildly by provider |
| Security Add-ons | DNSSEC, CAA support built-in | Basic or requires extra fees |
Common Mistakes and How to Fix Them
- Wrapping Values in Double Quotes: Cloudflare automatically manages quotation marks for standard TXT strings. Manually wrapping your content in quotes inside the dashboard can result in double-quoted strings that fail validation.
- Exceeding Character Limits: Standard DNS strings are limited to 255 characters per chunk. If your DKIM key is extremely long, split it into multiple quoted strings or let Cloudflare handle the chunking automatically during paste.
- Creating Multiple SPF Records: Having two separate TXT records starting with
v=spf1invalidates your SPF configuration entirely. Combine all authorized senders into a single record. - Typo in Subdomain Names: Omitting the leading underscore in records like
_dmarcorselector._domainkeyprevents mail servers from discovering your security policies.
Cloudflare DNS TXT Setup Checklist
- Logged into the correct Cloudflare account and selected your domain
- Verified that the record type is explicitly set to TXT
- Confirmed the host name uses the correct syntax (e.g.,
_dmarcor@) - Checked that string values do not contain conflicting manual quotation marks
- Tested propagation using
digor an online validation utility - Ensured only a single SPF record exists for the domain apex