What Is a DNS Record and What Each Type Does

Posted on

5 min read

A DNS record is one line in the phone book of the internet. When you type a domain name, DNS records tell your browser which server to contact, where email should go, and which services are allowed to send mail for that domain. Each record has a type, a name, a value, and a lifetime. The type decides what the record means.

You rarely see DNS records unless you manage a website or set up email. Then they become unavoidable, because a single wrong record can send visitors to the wrong server or block all incoming mail. Learning the five common record types covers most real problems, since the rest are rare or handled by specialists.

A DNS server zone file with record entries
A DNS zone file with record entries

What a DNS Record Is

DNS records live in a zone file hosted by your DNS provider. Each record maps a name to a piece of data. The name is usually the domain itself or a subdomain such as www or mail. The value depends on the type: an address, a hostname, or a block of text.

Every record also has a TTL, or time to live, measured in seconds. The TTL tells other servers how long they may cache the record before asking again. A short TTL of 300 seconds means changes spread in about five minutes. A long TTL of a day means changes can take a day to reach everyone.

Records are public. Anyone can look up the DNS records of any domain, so never put secrets in a record. Passwords, private keys, and internal addresses do not belong in DNS.

A Records and AAAA Records

An A record maps a name to an IPv4 address, such as 93.184.216.34. When a browser looks up example.com, the A record gives it the address to connect to. Most websites have an A record for the bare domain and another for www. If either is missing, that version of the address will not load.

An AAAA record does the same job for IPv6, using a much longer address. Many hosts now provide both, which is called dual stack. Visitors whose networks support IPv6 use the AAAA record, and everyone else uses the A record. If your host gives you an IPv6 address, add the AAAA record so those visitors get the faster path.

A common mistake is pointing the A record at an old server after a move. The site then loads the old copy or fails entirely. Check the A and AAAA records first whenever a move goes wrong, because they are the most likely cause and the fastest to fix.

MX, TXT, and CNAME Records

An MX record says where email for the domain should be delivered. It points to a mail server hostname and has a priority number. Lower numbers are tried first, so a backup mail server gets a higher number. Without an MX record, incoming mail has nowhere to go and senders get a bounce.

A TXT record holds free text, usually for verification or policy. Email authentication systems such as SPF, DKIM, and DMARC all publish their rules as TXT records. A website owner may also add a TXT record to prove domain ownership to a service.

A CNAME record makes one name an alias of another. For example, www can be a CNAME of the bare domain, so both names always point to the same place. A CNAME cannot sit on the bare domain itself, because the bare domain already needs other records.

TTL: How Long Records Live

TTL controls how fast a change spreads. Resolvers cache records for the TTL duration, so a record with a TTL of 86400 seconds can stay stale for a full day after you edit it. Before a planned move, lower the TTL to 300 seconds a day early, so caches expire quickly.

A low TTL is not free. Every lookup that misses the cache must ask your DNS provider again, which adds a small delay for visitors. For a stable site, a TTL of one hour to one day is a sensible balance. Only drop to five minutes when you expect to change records soon.

When testing a change, remember that your own computer and router also cache DNS. Flushing the local cache or testing from a fresh device avoids chasing a change that has already spread. Online DNS lookup tools show what the world sees, which is more reliable than one browser.

Reading a Zone File

A zone file is the full list of records for one domain. Reading it top to bottom, you can see the A records, the mail records, and the verification entries in one place.

Look for duplicates and leftovers first. An old A record from a previous host is the most common leftover, and it sends half your visitors to a dead server. A stray TXT record from a service you no longer use is harmless but confusing. Cleaning these up during a move prevents mysterious failures weeks later.

If a record looks wrong and you are unsure, change one record at a time and test after each change. DNS problems are hard to debug when three edits happen at once. Keep a copy of the old values before editing, so you can restore them if the change makes things worse.

One good project leads to another. See where NextDNS Setup: Blocking Ads and Trackers at the DNS Level takes you next.

Related Articles: