toolrota

What is DNS and how does it work? A guide to A, CNAME, MX and TXT records, propagation time and common DNS problems

DNS is the internet's phone book that turns domain names into server addresses. We explain how it works, the record types and problems when changing DNS.

Serkan Akyürek··9 min read
What is DNS and how does it work? A guide to A, CNAME, MX and TXT records, propagation time and common DNS problems – SaaS & Cloud

When you type a domain name in the browser the site opens within seconds; but behind the scenes a "translation" takes place. Computers find sites not by domain names but by IP addresses. The system that turns a domain name into an IP address is called DNS (Domain Name System). Most problems such as a site not opening, emails not arriving or a hosting change not showing relate to DNS. In this guide you learn what DNS is, how it works, the record types and how to fix common problems.

What is DNS?

Every server on the internet has an IP address (numbers such as 203.0.113.10). Because these are hard for people to memorise, domain names are used (for example example.com). DNS is a distributed system that answers the question "which IP address is example.com at?" The phone book comparison is common: you look up the name (domain) and find the number (IP address).

How does a DNS query work?

A site opening
  1. 1

    You type the domain name into the browser

  2. 2

    The device looks at its cache and the DNS resolver

  3. 3

    The resolver queries the root, the extension (.com) and the authoritative name servers in turn

  4. 4

    The authoritative server gives the IP address

  5. 5

    The browser connects to the server at that IP and fetches the page

The main players in this process:

  • DNS resolver: usually your internet provider's server or that of a public DNS service you choose. It makes the query for you and caches the result.
  • Root name servers: direct the query to the right extension server.
  • TLD servers: servers responsible for extensions such as .com, .org and .uk.
  • Authoritative name servers: servers that hold the domain's real records. They are usually at your domain or hosting provider.

Because results are cached, later visits are much faster. The cache time is set by the record's TTL value.

DNS record types

RecordWhat it doesExample
APoints the domain to an IPv4 addressexample.com → 203.0.113.10
AAAAPoints the domain to an IPv6 addressexample.com → 2001:db8::1
CNAMEMakes one name an alias of anotherwww → example.com
MXSays which server email goes toexample.com → mail server (with a priority value)
TXTText information; verification, SPF, DKIM, DMARC"v=spf1 ..."
NSStates the domain's authoritative name serversns1.provider.com
SRVServer and port for certain servicesSome communication services
CAALimits which certificate authorities can issue SSLletsencrypt.org
PTRReverse lookup from IP to domain nameImportant for email reputation

A and AAAA records

The most basic records connecting your website to a server. Your hosting provider gives you an IP address; you point the A record to it.

The CNAME record

Links one name to another. For example, for www.example.com a CNAME can point to example.com. A CNAME usually can't be used on the root domain (example.com); instead an A record or a special record type the provider supports is used. There must not be both a CNAME and another record for the same name.

The MX record

States which server emails are delivered to. If there are several MX records the one with the lowest priority value is tried first. If your email is with Google Workspace, Microsoft 365 or your hosting provider you must enter the MX records the provider gives (see our custom domain email guide). A wrong MX record causes emails not to arrive.

The TXT record

Carries text-based information. The most common uses: domain ownership verification (such as Google Search Console) and the SPF, DKIM and DMARC email authentication records. Configuring these correctly reduces emails landing in spam (see our SPF, DKIM, DMARC guide).

The NS record

States which servers manage your domain's DNS. By changing the name servers at the place where you bought the domain you can move DNS management to another provider (such as hosting or a service like Cloudflare).

TTL and propagation time

TTL (Time To Live) states for how many seconds a record stays cached in resolvers. A short TTL (for example 300 seconds) lets changes spread quickly; a long TTL (for example 86400 seconds) keeps the cache a long time.

What we call "DNS propagation" is resolvers around the world dropping the old cache and learning the new record after a change. The time can vary from minutes to 24–48 hours depending on the TTL, the provider and a name server change. Name server (NS) changes usually take longer.

Tip: if you plan a large migration, lower the TTL a few days before the move and raise it again once the move is done. This reduces downtime (on cloud migration and changing hosting see our domain and hosting guide).

Public DNS services

Your device uses your internet provider's DNS by default. If you like you can switch to a public DNS service such as Google (8.8.8.8), Cloudflare (1.1.1.1) or Quad9 (9.9.9.9). This can affect speed, privacy and security (such as filtering malicious sites). DNS-over-HTTPS (DoH) and DNS-over-TLS (DoT) encrypt queries. Still, changing DNS is no substitute for a VPN (see our VPN guide).

How to edit DNS records for a domain, step by step

  1. Sign in to your domain provider's or DNS management panel (the company where you bought the domain or a service hosting DNS such as Cloudflare).
  2. Save the existing records: take a screenshot or export the list.
  3. Decide which service you are adding a record for: website (A/CNAME), email (MX, SPF), verification (TXT).
  4. Add/change the record: name (host), type, value, TTL.
  5. Save and wait for propagation.
  6. Check (tools below).
  7. Review old, unused records; unnecessary records can create a security risk (for example a CNAME pointing to a service no longer used).

Checking DNS records

  • Command line: nslookup example.com or dig example.com (macOS/Linux) shows the A record; dig MX example.com shows the MX record.
  • Online tools: there are many free DNS check and propagation check sites.
  • Flushing the cache on Windows: ipconfig /flushdns
  • On macOS: depending on version sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
  • Browser cache: try a private window.

Common DNS problems and fixes

SymptomLikely causeFix
The site won't open, "address not found"A record missing/wrong, NS wrong, domain expiredCheck the records and the domain's expiry
The old site showsCache, propagation not finishedWait, clear the cache, try from a different network
Emails aren't arrivingMX record wrong or missingCorrect the MX records per the provider
Emails land in spamSPF/DKIM/DMARC missingAdd the TXT records
www opens, the root domain doesn'tNo A record for the rootAdd an A record to the root domain
SSL errorDNS points to the wrong server or the certificate doesn't matchCheck DNS and the certificate (see our SSL and HTTPS guide)
Opens on one network, not on anotherDifferent DNS cacheClear the cache, wait
CNAME conflictA CNAME and another record on the same nameRemove the conflicting record

DNS and security

  • DNS spoofing: altering the reply to a query; DNSSEC reduces this risk by signing replies.
  • Domain hijacking: protect your domain provider account with a strong password and two-factor authentication; turn on the registrar lock (see our domain and hosting guide).
  • Dangling DNS records: old records pointing to unused services can be abused by attackers.
  • Phishing domains: beware of fake look-alike domains (see our phishing guide).
  • Public DNS filtering: there are DNS services that block malicious sites for a family or organisation.

DNS when moving hosting or a site

  1. Prepare the new server and confirm it works with the hosts file (local test).
  2. Lower the TTL beforehand.
  3. Turn the A record to the new IP.
  4. Keep the email records (MX, SPF) intact; even if hosting changes, email can stay elsewhere.
  5. Keep the old server up until propagation is complete.
  6. Check verification and SSL.

Frequently asked questions

How long does a DNS change take? Usually minutes to a few hours; in some cases 24–48 hours.

Are DNS and hosting the same thing? No. Hosting is the server where your site's files sit; DNS makes the domain point to that server.

My domain is in one place and my hosting in another; where should DNS be? Usually entering the hosting provider's name servers at the domain, or keeping DNS at the domain provider and pointing the A record to the hosting IP, is enough.

Will the internet get faster if I change DNS? It can improve query times a little; it doesn't raise download speed.

**What is a wildcard (*) record?** It directs undefined subdomains to a certain target; use it carefully.

What happens to DNS if I use a CDN? CDNs usually ask for their own name servers or a CNAME redirect (see our CDN guide).

Summary

DNS is the system that turns domain names into IP addresses and forms the basis of your site, email and verifications. Knowing the A, CNAME, MX and TXT records, understanding TTL and propagation and saving the existing records before changing them prevents most problems. If you hit trouble, check the records first, then the cache and finally the domain's expiry.

Share
Published:
Author
Serkan Akyürek

Serkan Akyürek is the founder and author of toolrota; he writes step-by-step guides on Excel, AI, the cloud, personal finance and digital security.

Related guides

SaaS & Cloud
SaaS & Cloud8 min read

What is GitHub and how does it differ from Git? A beginner's guide: your first repository, commits, branches and pull requests

Git is a version control tool, while GitHub is the platform that hosts these projects and eases teamwork. We explain from opening your first repository to the pull request.

SaaS & Cloud4 min read

Reducing cloud costs: 8 mistakes that inflate the bill and ways to save

The cloud is flexible, but without control the bill grows fast. Practical ways to monitor cost, find unnecessary spend and cut it.

SaaS & Cloud4 min read

Google Workspace or Microsoft 365? An independent comparison for businesses

There are two big options for business email and office tools. We compared Google Workspace and Microsoft 365 by how your team works so you can decide step by step.

SaaS & Cloud5 min read

What is an API? What it does, how it works and everyday examples

Where does a weather app get its data and how does "Sign in with Google" work? The answer is an API. Explained without technical jargon.

SaaS & Cloud5 min read

NAS or cloud storage? Which is better for a home or small office

Store it on your own device or in the cloud? The strengths and weaknesses of both approaches, hidden costs and how to use them together.

Office & Productivity8 min read

How to build a productive morning routine: a realistic, sustainable and personal step-by-step guide

A good morning routine shapes the rest of the day, but it isn't the same for everyone. We explain a sustainable set-up from evening preparation to sample routines.