Skip to content

DNS Record Types: A, AAAA, CNAME, MX, TXT, SRV, NS — Complete Guide

DodaTech Updated 2026-06-23 4 min read

This tutorial covers every major DNS record type you will encounter when managing a domain on Cloudflare. You will learn the purpose, syntax, and configuration of A, AAAA, CNAME, MX, TXT, SRV, and NS records with working examples.

Why DNS Record Types Matter

Each DNS record type serves a distinct function: A and AAAA records map names to IP addresses, CNAME records create aliases, MX records route email, TXT records carry verification and security data, SRV records specify service locations, and NS records delegate authority. Using the wrong record type breaks your site, email, or services. Misconfigured records are one of the most common causes of downtime in production systems.

Real-world use: Durga Antivirus Pro uses TXT records for SPF and DKIM email authentication, A records for download servers, and SRV records for SIP-based threat intelligence feeds. Getting each type right is critical for both availability and security.

DNS Record Type Decision Flow

flowchart TD
  Q[What do you need to point?] --> R1[Root domain]
  Q --> R2[Subdomain]
  Q --> R3[Email]
  Q --> R4[Service discovery]
  R1 --> A[Use A or AAAA record]
  R2 --> C[Use CNAME record]
  R3 --> M[Use MX record]
  R4 --> S[Use SRV record]
  A --> T[Add TXT for verification]
  C --> T
  M --> T

A Record (Address Record)

Maps a domain name to an IPv4 address. This is the most fundamental record type — without it, browsers cannot find your server.

# Verify an A record
dig A example.com +short
# Expected output:
# 203.0.113.10
# Create an A record via Cloudflare API
curl -X POST "https://api.cloudflare.com/client/v4/zones/ZONE_ID/dns_records" \
  -H "Authorization: Bearer API_TOKEN" \
  -H "Content-Type: application/json" \
  --data '{
    "type": "A",
    "name": "@",
    "content": "203.0.113.10",
    "ttl": 120,
    "proxied": true
  }'
# Expected output:
# {"success":true,"result":{"type":"A","name":"example.com","content":"203.0.113.10"}}

AAAA Record (IPv6 Address Record)

Same purpose as an A record but for IPv6 addresses. Modern sites should have both A and AAAA records for dual-stack connectivity.

dig AAAA example.com +short
# Expected output:
# 2001:db8:3333:4444:5555:6666:7777:8888

CNAME Record (Canonical Name Record)

Creates an alias from one domain name to another. The most common use is pointing www.example.com to example.com.

dig CNAME www.example.com +short
# Expected output:
# example.com.

Important: A CNAME record cannot coexist with any other record at the same name. You cannot have a CNAME at the root domain (@) if you also need MX records there.

MX Record (Mail Exchange Record)

Directs email delivery to specific mail servers. Each MX record has a priority value; lower numbers are tried first.

dig MX example.com +short
# Expected output:
# 10 mail.example.com.
# 20 backup-mail.example.com.
# Configure MX records for Google Workspace
# Priority: 1, Target: ASPMX.L.GOOGLE.COM
# Priority: 5, Target: ALT1.ASPMX.L.GOOGLE.COM
# Priority: 5, Target: ALT2.ASPMX.L.GOOGLE.COM
# Priority: 10, Target: ALT3.ASPMX.L.GOOGLE.COM
# Priority: 10, Target: ALT4.ASPMX.L.GOOGLE.COM

TXT Record (Text Record)

Carries arbitrary text data, most commonly used for email authentication (SPF, DKIM, DMARC) and domain ownership verification.

dig TXT example.com +short
# Expected output (SPF record):
# "v=spf1 include:_spf.cloudflare.com ~all"

# DKIM record
dig TXT google._domainkey.example.com +short
# Expected output:
# "v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQ..."

SRV Record (Service Location Record)

Specifies the location of a specific service (protocol, port, and hostname). Used by SIP, LDAP, and Microsoft Exchange.

# SRV record format: priority weight port target
# _service._protocol.name TTL class SRV priority weight port target
dig SRV _sip._tcp.example.com +short
# Expected output:
# 10 5 5060 sipserver.example.com.

NS Record (Nameserver Record)

Delegates a subdomain to specific nameservers. Cloudflare automatically manages NS records for domains using their nameservers.

dig NS example.com +short
# Expected output:
# darl.ns.cloudflare.com.
# neil.ns.cloudflare.com.

FAQ

Can I use a CNAME at the root domain on Cloudflare?

Yes. Cloudflare supports CNAME flattening, which allows a CNAME record at the root apex. This is a Cloudflare-specific feature not available with standard DNS.

How many MX records can I have?

You can have multiple MX records for redundancy. Typical setups use 2-5 MX records with increasing priority values. Cloudflare recommends at least two for high availability.

What is the maximum length of a TXT record?

A single TXT record can be up to 255 characters per string, with multiple strings concatenated to reach a maximum total of 65,535 characters. Most providers recommend staying under 512 characters for compatibility.

Practice Questions

  1. Why can you not place a CNAME record at the root domain in standard DNS, and how does Cloudflare solve this?
  2. What is the difference between an A record and an AAAA record?
  3. How do MX record priorities determine email delivery order?

Summary

Each DNS record type serves a specific purpose: A/AAAA for IP mapping, CNAME for aliasing, MX for email routing, TXT for text data and authentication, SRV for service discovery, and NS for delegation. Using the correct type ensures your services remain reachable and your email passes authentication checks.

Built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro — security-first tools for the modern web.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro