DNS records are the instructions that tell the internet which IP address or service is associated with a domain name. When you type a domain into a browser, DNS records determine where your traffic is sent. This article explains the most common record types, what they do, and how to choose the right one for your needs.
What Are DNS Records?
DNS (Domain Name System) records are text entries stored on authoritative nameservers. Each record has a type, a name (like “example.com� or “www.example.com�), a value (like an IP address or another domain), and a TTL (time-to-live). The TTL tells resolvers how long to cache the record before asking again. The calculator above shows how many cache entries a resolver might hold given a query rate and TTL—useful for understanding cache load.
There are dozens of record types, but most websites only need a handful. The table below summarizes the ones you’ll encounter most.
| Type | Purpose | Example Value |
|---|---|---|
| A | Maps a hostname to an IPv4 address | 192.0.2.1 |
| AAAA | Maps a hostname to an IPv6 address | 2001:db8::1 |
| CNAME | Alias to another hostname | example.com |
| MX | Mail server for the domain | mail.example.com (priority 10) |
| TXT | Arbitrary text, often for verification | v=spf1 include:_spf.example.com ~all |
| NS | Authoritative nameserver for the domain | ns1.example.com |
| SOA | Start of authority—primary nameserver info | ns1.example.com admin.example.com 2025010101 |
| SRV | Service location (e.g., SIP, LDAP) | _sip._tcp.example.com 10 60 5060 sipserver.example.com |
| PTR | Reverse lookup—IP to hostname | host.example.com |
How DNS Records Work
When you type a domain like “example.com,� your device asks a recursive resolver (often run by your ISP or a public resolver) for the IP address. The resolver checks its cache; if nothing is there, it queries the root servers, then the .com TLD servers, then the authoritative nameservers listed in the domain’s NS records. The authoritative server returns the requested record (e.g., an A record) along with the TTL. The resolver caches that answer for the TTL duration, then repeats the process when the cache expires.
Each record type serves a specific function. For example, an A record points a hostname to an IPv4 address, while an AAAA record points to IPv6. CNAME records create an alias: if you have “www.example.com� as a CNAME to “example.com,� any query for the www name resolves to the same IP as the root domain. MX records specify which mail servers accept email for the domain, with priority numbers indicating preference (lower numbers are tried first). TXT records can hold any text, but are commonly used for SPF, DKIM, and domain ownership verification.
Choosing the Right Record Type
To decide which record you need, ask what you’re trying to do:
- Point a domain to a server: Use an A record for IPv4, AAAA for IPv6.
- Point a subdomain to the same server as another domain: Use a CNAME (but not for the root domain—CNAME at the apex can cause issues with MX and other records).
- Route email: Use MX records pointing to your mail server’s hostname, and add SPF/DKIM TXT records for authentication.
- Verify domain ownership: Add a TXT record with the verification code provided by your service (e.g., Google or Microsoft).
- Set up a service like VoIP or LDAP: Use SRV records with the service and protocol prefix (e.g., _sip._tcp).
- Reverse DNS (for mail servers or security): Use PTR records, usually managed by your hosting provider.
Remember that NS records define which nameservers are authoritative for your domain—you usually set these at your registrar, not in your DNS zone.
Common DNS Record Mistakes
Misconfiguring DNS can cause outages, email failures, or security issues. Here are frequent pitfalls:
- Using CNAME at the root domain: Many providers allow it, but it can break MX or NS lookups because the root domain must have actual records, not just an alias. Prefer an A/AAAA record at the apex.
- Ignoring TTL: A very long TTL (e.g., 86400) means changes take up to 24 hours to propagate. Lower the TTL before making changes, then raise it back after.
- Forgetting trailing dot in fully qualified domain names: In DNS zone files, a hostname like “mail.example.com.� must end with a dot; otherwise it is interpreted as relative to the zone.
- Mixing up A and CNAME: You can’t have both an A and a CNAME for the same name—the CNAME takes precedence and the A is ignored.
- Not updating MX when changing email provider: Old MX records can cause mail to go to a decommissioned server.
What Are the Costs and Limits?
DNS itself is free—you pay for the domain registration and possibly for a DNS hosting service if you use a premium provider. Most registrars include free DNS hosting with the domain. There are practical limits: a single DNS response should stay under 512 bytes for UDP (without EDNS), though modern resolvers support larger responses. TXT records have a 255-character limit per string, but you can concatenate multiple strings. The number of records per zone is not strictly limited, but performance degrades with very large zones.
DNS Security and Safety
DNS is a common attack vector. DNSSEC (DNS Security Extensions) adds cryptographic signatures to records, preventing spoofing and cache poisoning. However, DNSSEC requires extra setup and key management. Other safety practices:
- Use strong, unique passwords for your DNS provider account.
- Enable two-factor authentication if available.
- Regularly audit your records for unknown entries.
- Use CAA records to restrict which certificate authorities can issue SSL certificates for your domain.
- Be cautious with wildcard records (*.example.com)—they can expose subdomains you didn’t intend.
If you’re not sure about a change, test it with a tool like dig or an online DNS checker before updating the live zone.
Frequently Asked Questions
What is the difference between A and AAAA records?
A records map a hostname to an IPv4 address (e.g., 192.0.2.1). AAAA records map to an IPv6 address (e.g., 2001:db8::1). If your server supports IPv6, you should have both; otherwise, only A is needed.
Can I use a CNAME for my root domain?
Technically, some DNS providers allow it, but it’s not recommended because the root domain also needs MX, NS, and SOA records. A CNAME at the apex can cause those to be ignored or misbehave. Use an A/AAAA record for the root and CNAMEs for subdomains.
What does TTL mean and what value should I use?
TTL (time-to-live) is how long a resolver caches the record in seconds. Common values: 300 (5 min) for testing, 3600 (1 hour) for normal use, and 86400 (24 hours) for stable records. Lower TTLs make changes propagate faster but increase query load on your nameserver.
Why do I need TXT records for email?
TXT records are used for SPF (Sender Policy Framework), DKIM (DomainKeys Identified Mail), and DMARC policies. These help email servers verify that messages claiming to be from your domain are legitimate, reducing spam and phishing. Without them, your emails may be marked as spam.
What is a PTR record and do I need one?
A PTR record maps an IP address back to a hostname—the reverse of an A record. It’s used for reverse DNS lookups, often by mail servers to verify that the sending server’s IP matches its hostname. You usually need to create PTR records with your hosting provider, not in your own DNS zone.
How long does DNS propagation take?
Propagation time depends on the TTL of the old records and how quickly resolvers refresh their cache. With a TTL of 3600, changes can take up to an hour to fully propagate, but it often happens in minutes. For urgent changes, lower the TTL beforehand.
Related
Formula used
in t | TTL (seconds) | sec | 3600 | 0 | 86400 in q | QPS (queries/sec) | - | 100 | 1 | 1000000 out ans | Cache entries | - | q * t | 0
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- OLED TVs in Dark Rooms: Why They Look Better and When They Don’t
- Philips DST7060/20 7000 Series Iron: Specs & Fit
- Coal Fueled Jet Aircraft: Could It Work?675 L
- Remote Desktop on Raspberry Pi: How to Enable It
- Word Select Last Line in Paragraph?
- Google Assistant IFTTT Recipes: 7 Useful Automations