Technical Guides

What Is DNS and How DNS Records Work

What DNS is, how the browser finds a site by its domain name, the main DNS records (A, AAAA, CNAME, MX, TXT, NS, CAA) and why your email lands in spam without SPF, DKIM and DMARC.

dnswhat is dnsdns recordsdomainhosting

DNS (Domain Name System) is the system that translates domain names into IP addresses. When you type tanchev.net, the browser does not know where that site is. DNS tells it which server to go to. Think of it as the phone book of the internet: you remember the name, the phone book keeps the number.

I wrote the first version of this article in 2022. This one is updated with the things businesses actually run into: moving to new hosting, email landing in spam, and records nobody remembers adding.

Why DNS is needed

Every device on the internet has an IP address: an IPv4 one such as 188.114.96.3 or a longer IPv6 one, for example 2606:4700:3030::6815:2a2a. People cannot remember addresses like that, and they change when a site moves to another server. The domain stays the same; only the DNS record that points to the new address changes. I explain what a domain is and which parts it has in the article what is a domain.

How DNS works: the path of one request

When you open a site, the browser and the operating system first check whether they remember the address from a recent visit. If not, the request goes through several servers:

  1. The recursive resolver. This is the middleman, usually run by your internet provider, or a public one such as Cloudflare (1.1.1.1) and Google (8.8.8.8). It does the lookup for you and caches the answers.
  2. The root servers. The resolver asks them where to look for the extension, for example .net. The root servers are 13 logical addresses run by 12 organisations at hundreds of locations worldwide, and the content of the root zone is managed by IANA.
  3. The extension (TLD) servers. They know which servers are responsible for each domain with that extension and point the resolver to them.
  4. The domain’s authoritative server. It holds the real records of the domain and answers with the IP address.

The resolver returns the address to the browser, and the browser loads the site. The whole path usually takes milliseconds, and on the next visit the answer comes straight from the cache.

The main DNS records

DNS records are the lines in the domain’s zone that say what is where. These are the ones you will meet in your registrar’s panel or in Cloudflare:

  • An A record links a name to an IPv4 address. For example, tanchev.net points to the server’s IP address.
  • An AAAA record does the same for an IPv6 address.
  • A CNAME record is an alias: it points one name to another name, never to an IP address. For example, www.tanchev.net to tanchev.net. A CNAME cannot be placed on the main domain itself, only on a subdomain.
  • An MX record says where email for the domain is delivered, for example to Google Workspace or to the hosting’s mail server.
  • A TXT record holds text used for checks: ownership verification for Google Search Console and, most importantly, the email rules (SPF, DKIM, DMARC).
  • An NS record says which servers are authoritative for the domain. Change the NS records and you change where the whole DNS is managed.
  • A CAA record sets which certificate authorities may issue an SSL certificate for the domain.

Why the email from your site lands in spam

The most common DNS problem I see at businesses has nothing to do with the website itself; it is about email. The contact form “works”, but the messages land in spam or never arrive. The cause is almost always in the TXT records:

  • SPF lists the servers that are allowed to send mail on behalf of the domain.
  • DKIM adds a digital signature to every message, which the recipient checks against a public key in DNS.
  • DMARC tells mail servers what to do with messages that fail SPF and DKIM, and where to send reports.

Gmail and Yahoo now require these records from senders of larger volumes of mail, and even at small volumes messages without them get lost easily. If the site sends through an external service such as Brevo or Google Workspace, that service must be included in SPF and have a DKIM record.

TTL and DNS “propagation”

Every record has a TTL (time to live): how many seconds resolvers may keep the answer in their cache. If the TTL is 3600, a change can take up to an hour to reach everyone. That is why, before a planned move of a site, it is a good idea to lower the TTL to 300 seconds a day earlier and raise it again after the move.

When people say “DNS takes up to 48 hours to propagate”, it is exactly this cache they mean. The change itself is instant on the authoritative server; you are waiting for the old answers to expire.

Practical advice

  • Document your records. Before you change hosting or DNS provider, export the whole zone. A lost MX or TXT record means your email stops.
  • Do not delete records you do not recognise before checking what they are for. They are often verifications for services you still use.
  • Check with external tools. The dig command or online checkers show what others see, not what the panel says.
  • Cloudflare and the proxy. If the domain is on Cloudflare with the orange cloud on, the A record resolves to a Cloudflare IP address, not to your server. That is normal and hides the real server.

If you would rather not deal with DNS, hosting and email, that is part of my server administration service: I set up the records, the email and SSL, and keep the server running. For a new site, the DNS setup is included in website development.

Related Articles