DNS Explained: The Internet's Directory
Learn how the Domain Name System turns names into addresses, who runs each part of it and what to check when it breaks.
Key takeaways
- DNS translates domain names into data, most often the IP addresses that devices use to reach each other.
- The system is a tree: the root points to top-level domains, which point to the name servers for individual domains.
- A resolver does the searching on your behalf and keeps answers in a cache for as long as each record's time to live allows.
- Whoever controls a domain's DNS controls where its website and email go, so that account deserves strong protection.
The Domain Name System, or DNS, is the service that turns a name you can remember, such as www.example.com, into the numeric address a computer needs in order to connect. When you open a website, send an email or start an app, your device asks DNS where to go before any real data moves.
DNS works like a directory with no single central copy. The information is split among a huge number of servers, each responsible for its own slice, and your device finds the right slice by following referrals. Once you understand that structure, most DNS problems and settings start to make sense.
Why names need a directory
Every device on the internet is reached by an IP address. An IPv4 address looks like 192.0.2.10, and an IPv6 address looks like 2001:db8::10. Those numbers are fine for routers and awkward for people. They also change: a company can move its website to a different server or a different hosting provider overnight.
A name solves both problems. You remember example.com, and the owner of that name decides which address it currently points to. When the server moves, the owner updates one entry in DNS and visitors follow along without learning anything new.
In the early days of the network, a single text file listed every host and its address, and each machine copied it. That approach stops working once many organizations are adding and renaming machines all the time. DNS, specified in RFC 1034 and RFC 1035, replaced the one big file with a distributed database where each organization manages its own part.
How a name is structured
Read a domain name from right to left to see the hierarchy. In www.example.com. there are four levels:
- The final dot is the root, the starting point of the whole tree. You normally leave it off when typing.
-
comis the top-level domain (TLD). -
exampleis the domain someone registered under that TLD. -
wwwis a hostname or subdomain that the domain's owner created.
Each dot-separated piece is called a label. A label can be up to 63 characters, and the full name has an upper limit of about 253 characters in the form you type. Names are not case-sensitive, so Example.COM and example.com are the same.
The hierarchy matters because it is also a chain of responsibility. The people who run the root only need to know who runs each TLD. The com registry only needs to know which name servers answer for example.com. The owner of example.com publishes the actual details, and can create as many names underneath as they like without asking anyone.
Who does the work
Four kinds of software take part in a typical lookup.
The stub resolver is the small piece built into your phone or computer. It does not search the tree itself. It sends a question to a bigger server and waits for the answer.
The recursive resolver does the searching. Your internet provider runs one, and public operators offer others. It asks as many questions as needed and returns a finished answer.
Authoritative name servers hold the official records for a zone, which is a portion of the tree managed as one unit. They answer only for what they are responsible for.
Root and TLD servers are authoritative servers too, but their answers are mostly referrals: "I don't hold that record, ask these servers instead."
The split between the first two jobs and the last two is covered in more detail in recursive vs. authoritative DNS servers.
What a lookup looks like
Say your laptop wants www.example.com and nothing is cached anywhere. The resolver starts at the top and works down.
In practice, the resolver rarely has to do all of that. It has usually seen the com servers recently, and it may already hold the final answer because another user asked a moment ago. Your operating system and browser keep small caches of their own too. The full walk is described step by step in what happens during a DNS lookup.
Traditional DNS uses port 53, mostly over UDP, which suits short question-and-answer exchanges. It switches to TCP when an answer is too large and for transferring whole zones between servers.
The records DNS stores
A DNS entry is called a record. Each has a name, a type, a time to live and a value. These are the types you will meet most often.
| Type | What it holds | Typical use |
|---|---|---|
| A | An IPv4 address | Pointing a name at a server |
| AAAA | An IPv6 address | The same, for IPv6 |
| CNAME | Another name | Making one name an alias of another |
| MX | A mail server name and preference | Delivering email |
| TXT | Free-form text | Email policies, ownership proofs |
| NS | A name server | Saying who is authoritative |
| SOA | Zone administration data | One per zone, at its top |
A record looks like this in the text format that many tools use:
www.example.com. 3600 IN A 192.0.2.10
www.example.com. 3600 IN AAAA 2001:db8::10
example.com. 3600 IN MX 10 mail.example.com. The number 3600 is the time to live in seconds: how long a resolver may reuse the answer before asking again. IN means the internet class, which is what you will see in nearly every case. For the two address types, see A and AAAA records explained.
Caching makes it fast and a little slow to change
If every lookup went all the way to the root, DNS would be slow and the top servers would be swamped. Caching prevents that. A resolver remembers each answer until its time to live runs out.
The cost is that changes are not instant. If your record has a one-hour time to live and you edit it, some visitors may keep getting the old address for up to an hour. People often call this "propagation", although nothing is being pushed outward. Old copies are simply expiring one by one. DNS caching and time to live shows how to plan around it.
Owning a domain and running its DNS
Registering a domain and hosting its DNS are related but separate jobs. A registrar is the company you pay to register the name. A DNS host runs the authoritative name servers that answer questions about it. Many registrars include DNS hosting, and many people use a different provider for it.
The link between the two is the list of name servers saved at the registrar. Change that list and you hand control of every record to whoever runs the new servers. This is why the registrar and DNS accounts are high-value targets. Use a unique password and multi-factor authentication on both, and keep the contact email current. The broader process is explained in how domain registration works.
Checking DNS yourself
You can ask DNS questions directly. On Windows, macOS or Linux, nslookup is usually available:
nslookup www.example.com
nslookup -type=mx example.com On macOS and many Linux systems, dig gives more detail:
dig www.example.com A
dig example.com NS +short Windows PowerShell has its own command:
Resolve-DnsName example.com -Type MX If a name fails to resolve but you can still reach services by IP address, DNS is a strong suspect. Try a second device on the same network, then the same device on a different network such as a phone hotspot. If only one network fails, look at its resolver or router. If one name fails everywhere, the problem is likely with that domain's records or name servers. Using nslookup and dig to debug DNS goes further.
Why DNS matters more than it looks
DNS does more than turn one name into one address. Because the owner of a zone decides what to answer, DNS is also a control point for how services behave.
- Spreading load. A name can return several addresses, or different addresses to people in different places, so visitors are shared among servers.
- Moving services. Changing a record redirects traffic to a new provider without asking users to do anything.
- Delivering mail. MX records tell other mail systems which servers accept messages for your domain.
- Proving ownership. Many services ask you to publish a specific TXT record, which only someone controlling the domain can do.
- Filtering. A resolver can refuse to answer for known malicious or unwanted names, which blocks them for every device that uses it.
That reach explains why a DNS fault can look like something much bigger. If a popular DNS provider has trouble, many unrelated websites may seem to be down at once, even though their web servers are running normally. Visitors simply cannot find them.
What DNS does not do
DNS tells you where to connect. It does not prove that the answer is honest, and it does not hide your questions from people on the path. Separate additions address those gaps: DNSSEC lets resolvers verify that records were signed by the zone's owner, while encrypted DNS protects the link between your device and the resolver.
DNS also does not make a website secure. A name can resolve perfectly to a server run by a scammer. Check the spelling of the domain, and treat the browser's HTTPS indicator as proof of an encrypted connection to that name, not proof that the owner is trustworthy.