DNS Record Types Reference

DNS record types reference β€” A, AAAA, CNAME, MX, TXT, NS, SOA, PTR, SRV explained. What each record does, when to use it, and real examples.

6 min read

DNS Record Types Reference Cheatsheet

What it is

A reference for common DNS record types, explaining their purpose and typical usage.

Installation

N/A (This is a reference, not a tool to install).

Core Concepts

DNS (Domain Name System) is a hierarchical and decentralized naming system for computers, services, or any resource connected to the Internet or a private network. It translates human-readable domain names (like www.example.com) into machine-readable IP addresses (like 192.0.2.1). DNS records are entries within a DNS server that store information about a domain.

Commands / Usage

Address Records

  • A Record (Address Record)

    • Purpose: Maps a hostname to an IPv4 address.
    • Example: www.example.com. IN A 192.0.2.1
      • www.example.com. is the hostname.
      • IN indicates the Internet class.
      • A is the record type.
      • 192.0.2.1 is the IPv4 address.
  • AAAA Record (IPv6 Address Record)

    • Purpose: Maps a hostname to an IPv6 address.
    • Example: ipv6.example.com. IN AAAA 2001:0db8::1
      • ipv6.example.com. is the hostname.
      • IN indicates the Internet class.
      • AAAA is the record type.
      • 2001:0db8::1 is the IPv6 address.

Mail Exchange Records

  • MX Record (Mail Exchanger Record)
    • Purpose: Specifies the mail servers responsible for receiving email for a domain. Includes a priority value (lower number means higher priority).
    • Example: example.com. IN MX 10 mail.example.com.
      • example.com. is the domain.
      • IN indicates the Internet class.
      • MX is the record type.
      • 10 is the priority.
      • mail.example.com. is the mail server hostname.
    • Example (multiple servers):
      example.com. IN MX 10 mail1.example.com.
      example.com. IN MX 20 mail2.example.com.
      

Alias and Canonical Name Records

  • CNAME Record (Canonical Name Record)

    • Purpose: Creates an alias, mapping a hostname to another hostname (the canonical name). Useful for pointing subdomains to services without managing IP addresses directly.
    • Example: www.example.com. IN CNAME server.example.net.
      • www.example.com. is the alias hostname.
      • IN indicates the Internet class.
      • CNAME is the record type.
      • server.example.net. is the canonical hostname.
    • Note: A CNAME cannot coexist with other record types for the same hostname (except for DNSSEC related records like RRSIG, NSEC, etc.).
  • ALIAS Record (Proprietary/Non-Standard)

    • Purpose: Similar to CNAME but often used at the root of a domain (e.g., example.com) where CNAMEs are not allowed. It effectively resolves to an IP address behind the scenes. Support varies by DNS provider.
    • Example (conceptual, syntax varies): example.com. IN ALIAS lb.example.com.

Text Information Records

  • TXT Record (Text Record)
    • Purpose: Holds arbitrary text data. Commonly used for domain verification (e.g., SPF, DKIM, DMARC records for email authentication) and site ownership verification.
    • Example (SPF): example.com. IN TXT "v=spf1 include:_spf.google.com ~all"
    • Example (Domain Verification): _dmarc.example.com. IN TXT "v=DMARC1; p=none;"

Name Server Records

  • NS Record (Name Server Record)
    • Purpose: Delegates a DNS zone to use the given name servers. Crucial for domain delegation and defining authoritative name servers.
    • Example: example.com. IN NS ns1.nameserver.com.
      • example.com. is the domain.
      • IN indicates the Internet class.
      • NS is the record type.
      • ns1.nameserver.com. is the authoritative name server.

Start of Authority Records

  • SOA Record (Start of Authority Record)
    • Purpose: Provides authoritative information about a DNS zone, including the primary name server, administrator’s email, serial number, and timers relating to zone refresh and expiry. Every zone MUST have an SOA record.
    • Example: example.com. IN SOA ns1.nameserver.com. admin.example.com. ( 2023010101 7200 3600 1209600 3600 )
      • example.com. is the zone.
      • IN indicates the Internet class.
      • SOA is the record type.
      • ns1.nameserver.com. is the primary name server.
      • admin.example.com. is the administrator’s email (replace . with @).
      • 2023010101 is the serial number.
      • 7200 is the refresh interval (seconds).
      • 3600 is the retry interval (seconds).
      • 1209600 is the expire limit (seconds).
      • 3600 is the minimum TTL (seconds).

Service Location Records

  • SRV Record (Service Locator Record)
    • Purpose: Specifies the location (hostname and port) of servers for specific services.
    • Example: _sip._tcp.example.com. IN SRV 10 60 5060 sipserver.example.com.
      • _sip._tcp.example.com. is the service and protocol.
      • IN indicates the Internet class.
      • SRV is the record type.
      • 10 is the priority.
      • 60 is the weight.
      • 5060 is the port.
      • sipserver.example.com. is the target hostname.

Other Common Record Types

  • PTR Record (Pointer Record)

    • Purpose: Used for reverse DNS lookups, mapping an IP address back to a hostname.
    • Example: 1.2.0.192.in-addr.arpa. IN PTR www.example.com.
      • 1.2.0.192.in-addr.arpa. is the reverse lookup domain for 192.0.2.1.
      • IN indicates the Internet class.
      • PTR is the record type.
      • www.example.com. is the associated hostname.
  • CAA Record (Certification Authority Authorization)

    • Purpose: Specifies which Certificate Authorities (CAs) are allowed to issue SSL/TLS certificates for a domain.
    • Example: example.com. IN CAA 0 issue "letsencrypt.org"
      • example.com. is the domain.
      • IN indicates the Internet class.
      • CAA is the record type.
      • 0 is the flag (0 means issue).
      • issue is the tag.
      • "letsencrypt.org" is the allowed CA.

Common Patterns

  • Checking DNS Records: Using dig or nslookup to query specific record types.

    • dig www.example.com A
    • dig example.com MX
    • dig example.com TXT
    • nslookup -type=MX example.com
  • Verifying Email Configuration: Checking MX, TXT (for SPF/DKIM/DMARC) records.

    • dig example.com MX +short
    • dig example.com TXT +short
  • Setting up a Subdomain: Using A, AAAA, or CNAME records.

    • blog.example.com. IN A 192.0.2.10
    • docs.example.com. IN CNAME gh-pages.github.io.

Gotchas

  • Trailing Dots: Hostnames in DNS records usually require a trailing dot (.) to indicate the end of the FQDN (Fully Qualified Domain Name). Omitting it might cause the DNS server to append the default domain, leading to incorrect records.
  • CNAME Restrictions: A CNAME record cannot coexist with any other record types for the same hostname, except for DNSSEC-related records. This means you cannot have a CNAME and an A record for www.example.com simultaneously. You also cannot place a CNAME at the zone apex (e.g., example.com).
  • TTL (Time To Live): This value determines how long a DNS resolver caches a record. Lower TTLs mean changes propagate faster but can increase DNS query load. Higher TTLs reduce load but slow down propagation.
  • IP Address vs. Hostname: Be careful whether a record points to an IP address (A, AAAA) or another hostname (CNAME, MX, SRV).
  • Record Syntax: The exact syntax for creating records can vary slightly between DNS providers’ control panels. However, the fundamental structure (name, class, type, value) remains consistent.
  • Reverse DNS (PTR): PTR records are managed in a special domain (in-addr.arpa for IPv4, ip6.arpa for IPv6) and are typically managed by the entity that owns the IP address block, not the domain owner.