- What is DNS?Computers find each other by numeric IP addresses, such as 203.0.113.10 or 2001:db8::10.
- How does a DNS lookup work?Most lookups finish in milliseconds because a nearby resolver already has the answer.
- Which servers take part in DNS?The authoritative nameservers for your domain are the ones you set at your registrar; see nameservers explained.
What is DNS?
Computers find each other by numeric IP addresses, such as 203.0.113.10 or 2001:db8::10. People prefer names. DNS is the system that translates one into the other, so you can type example.com and reach the right server. It was designed in the 1980s and is defined in RFC 1034 and RFC 1035. It is distributed: no single computer holds every answer. Instead, responsibility is split into zones, each run by the owner of a domain or the company they chose.
DNS does more than find websites. It tells mail servers where to deliver email, proves that you own a domain to services that ask, and publishes the text records that help stop forged email. When DNS fails, sites and email can disappear even though the servers are running fine.
How does a DNS lookup work?
Most lookups finish in milliseconds because a nearby resolver already has the answer. The full walk happens only the first time, or after a cached answer expires.
- Your device asks a resolver
Usually run by your internet provider or a public service.
- The resolver checks its cache
If it has a fresh answer it replies at once.
- Otherwise it walks the hierarchy
Root servers, then the .com servers, then your domain's nameservers.
- The authoritative nameserver answers
It returns the record, such as the IP address for the name.
- The resolver caches and replies
Your browser connects to the address.
Which servers take part in DNS?
The authoritative nameservers for your domain are the ones you set at your registrar; see nameservers explained.
| Part | Role |
|---|---|
| Stub resolver (your device) | Asks a recursive resolver and passes the answer to the application |
| Recursive resolver | Does the work of finding an answer and caches it |
| Root servers | Know where to find each top-level domain |
| TLD servers | Know which nameservers a domain uses (for .com, .org, .uk and so on) |
| Authoritative nameservers | Hold the records for a domain and give the official answer |
What do DNS records contain?
Each record has a name, a type, a value and a time to live. The common types are A and AAAA for addresses, CNAME for aliases, MX for mail, TXT for text such as SPF and verification codes, and NS for the nameservers themselves. Our guide to DNS records explains each type with examples, and our DNS lookup tool shows the records a domain currently returns.
What are caching and TTL?
Every record carries a TTL, the number of seconds resolvers may keep an answer. A long TTL reduces load and speeds up lookups but delays changes; a short TTL makes changes quick but increases queries. “Propagation” is just caches expiring at different times. Lower the TTL a day before a planned change, make the change, then raise it again. Your browser and operating system also keep their own short-lived caches, which is why a private window or another network sometimes shows the change first.
How does DNS connect to hosting and email?
- Hosting: the A or AAAA record points your domain to the server; see how to point a domain to your hosting.
- Email: MX records choose the mail server, and SPF, DKIM and DMARC records help receivers trust your mail; see email hosting vs web hosting.
- Security certificates: certificate authorities check DNS or the server to confirm you control a domain; see what an SSL certificate is.
- CDNs and proxies: you change nameservers or records to route traffic through them; see what a CDN is.
- Moves: DNS is the switch that points visitors to a new host; see the website migration checklist.
What is DNSSEC and is DNS secure?
Plain DNS has no built-in proof that an answer is genuine, so attackers can try to forge answers, a problem known as cache poisoning. DNSSEC adds digital signatures to records so that a validating resolver can tell whether an answer is authentic. It is optional, needs support from the registrar and DNS provider, and a misconfiguration can make a domain fail to resolve, so follow your provider’s guide when you enable it or change providers. Other protections include DNS over HTTPS and over TLS, which encrypt the query between your device and the resolver.
How do you troubleshoot DNS problems?
- Look up the exact name and record type with a lookup tool and compare the result with what you expect.
- Query the authoritative nameserver directly to see the true value, then a public resolver to see what the world sees.
- Check for a typo, a missing www record or a CNAME where other records exist.
- Wait for the old TTL to expire before assuming a change failed.
- Check that the nameservers at the registrar are the ones where you edited records.
- Check DNSSEC if validating resolvers fail but others work.
What are the common mistakes?
- Changing nameservers without copying every record, so email stops.
- Editing records at a provider that is not the authoritative one.
- Leaving a long TTL before a migration.
- Forgetting that example.com and www.example.com are different names.
- Deleting records you do not recognise, such as verification TXT records that a service still uses.
A worked example: what happens when you type a web address
You type www.example.com in your browser. The browser checks its own cache and then asks the operating system, which checks its cache and then your resolver. The resolver has no answer, so it asks a root server where to find the .com servers, asks a .com server which nameservers hold example.com, and asks one of those for the A record of www. The answer comes back as an address with a TTL of 300 seconds. The resolver stores it for five minutes and gives it to your computer, which connects to that address over HTTPS and asks for the page.
If you reload a minute later, none of this repeats: the answer is already in cache. If the site owner changes the address, you will keep using the old one for up to five minutes. If the same resolver serves many people, they all benefit from the first lookup, which is why DNS scales so well.
Who runs your DNS: registrar, host or a dedicated provider?
The choice is made by the nameservers you set at the registrar. Our nameservers guide explains how to change them safely, and do you need Cloudflare? covers the most common dedicated option.
| Where DNS lives | Good for | Watch out for |
|---|---|---|
| Registrar | Keeping DNS separate from hosting under one login | Features may be basic |
| Web host | Automatic records for site and email | Moving hosts means moving DNS |
| Dedicated DNS or CDN provider | Speed, security and independence | Another account and settings to manage |