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.1www.example.com.is the hostname.INindicates the Internet class.Ais the record type.192.0.2.1is the IPv4 address.
-
AAAA Record (IPv6 Address Record)
- Purpose: Maps a hostname to an IPv6 address.
- Example:
ipv6.example.com. IN AAAA 2001:0db8::1ipv6.example.com.is the hostname.INindicates the Internet class.AAAAis the record type.2001:0db8::1is 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.INindicates the Internet class.MXis the record type.10is 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.INindicates the Internet class.CNAMEis 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.
- Purpose: Similar to CNAME but often used at the root of a domain (e.g.,
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.INindicates the Internet class.NSis 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.INindicates the Internet class.SOAis the record type.ns1.nameserver.com.is the primary name server.admin.example.com.is the administratorβs email (replace.with@).2023010101is the serial number.7200is the refresh interval (seconds).3600is the retry interval (seconds).1209600is the expire limit (seconds).3600is 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.INindicates the Internet class.SRVis the record type.10is the priority.60is the weight.5060is 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 for192.0.2.1.INindicates the Internet class.PTRis 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.INindicates the Internet class.CAAis the record type.0is the flag (0 means issue).issueis the tag."letsencrypt.org"is the allowed CA.
Common Patterns
-
Checking DNS Records: Using
digornslookupto query specific record types.dig www.example.com Adig example.com MXdig example.com TXTnslookup -type=MX example.com
-
Verifying Email Configuration: Checking
MX,TXT(for SPF/DKIM/DMARC) records.dig example.com MX +shortdig example.com TXT +short
-
Setting up a Subdomain: Using
A,AAAA, orCNAMErecords.blog.example.com. IN A 192.0.2.10docs.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
CNAMErecord cannot coexist with any other record types for the same hostname, except for DNSSEC-related records. This means you cannot have aCNAMEand anArecord forwww.example.comsimultaneously. You also cannot place aCNAMEat 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.arpafor IPv4,ip6.arpafor IPv6) and are typically managed by the entity that owns the IP address block, not the domain owner.