DNS

How DNS Resolves a Domain Name

By NetworkSkies Editorial Team · · 5 min read

Computers find each other by numeric addresses, but people prefer names. The Domain Name System, or DNS, is the global directory that translates a name such as example.com into the address a computer needs to connect. Almost every action you take online starts with a DNS lookup, usually in a few milliseconds and without you noticing.

DNS is not a single database. It is a distributed system, spread across millions of servers and organized as a hierarchy. Understanding how a lookup moves through that hierarchy helps with troubleshooting, performance tuning and security.

The cast of characters

A lookup involves several kinds of servers, each with a specific role.

  • Stub resolver. A small component in your operating system or browser that asks for answers on your behalf.
  • Recursive resolver. A server, often run by your internet provider or a public DNS service, that does the legwork of finding the answer and caches the result.
  • Root name servers. The top of the hierarchy. They know which servers handle each top-level domain, such as .com or .org.
  • TLD name servers. These servers know which name servers are responsible for each domain registered under a top-level domain.
  • Authoritative name servers. The servers that hold the real records for a domain and give the final answer.

A lookup step by step

Say you type www.example.com into your browser.

  1. Local caches. Your browser and operating system first check whether they already know the answer. If so, the process ends immediately.
  2. Ask the recursive resolver. If not, the stub resolver sends the question to your configured recursive resolver.
  3. Resolver cache. The resolver checks its own cache. Popular names are usually already stored there.
  4. Ask a root server. On a cache miss, the resolver asks a root server where to find .com names. The root does not know the answer, but it replies with a referral to the .com servers.
  5. Ask the TLD server. The resolver asks a .com server about example.com. It replies with the addresses of the authoritative servers for that domain.
  6. Ask the authoritative server. The resolver asks one of those servers for www.example.com. This server holds the actual record and returns the address.
  7. Return and cache. The resolver sends the answer to your device, and keeps a copy for future requests.
  8. Connect. Your browser uses the address to open a connection to the website.

You can watch this process with the dig tool, which supports a trace mode.

dig +trace www.example.com

The output shows each referral from the root downward until the final answer appears.

Recursive and iterative queries

Two styles of questioning appear in this process. Your device asks the resolver a recursive query, meaning "get me the final answer, however you need to." The resolver then asks others iterative queries, where each server answers with either the result or a referral to a better source. This division keeps the infrastructure efficient, because simple devices do not need to understand the hierarchy.

Caching and TTL

If every lookup went all the way to the root, the system would collapse under the load. Caching prevents this. Each DNS record includes a time to live (TTL), a number of seconds that says how long others may keep the answer before asking again.

  • A long TTL reduces traffic and speeds up repeat lookups, but changes take longer to spread.
  • A short TTL lets changes take effect quickly, which suits a planned server move, but increases the number of queries.

This is why a DNS change is sometimes described as "propagating." Nothing is really being pushed out. Caches around the world simply expire at different times.

Common record types

DNS stores more than addresses. These record types come up often.

  • A maps a name to an IPv4 address.
  • AAAA maps a name to an IPv6 address.
  • CNAME makes one name an alias of another.
  • MX says which servers receive email for the domain.
  • TXT holds free-form text, used for email authentication and domain verification.
  • NS lists the authoritative name servers for a domain.
  • PTR provides reverse lookup, mapping an address back to a name.
  • SOA holds administrative details about a zone.

DNS and security

Plain DNS was designed in a more trusting era, and its queries travel unencrypted by default. Several problems follow.

  • Spoofing and cache poisoning. An attacker may try to insert a false answer, sending users to a fake site. DNSSEC addresses this by adding digital signatures to records so resolvers can verify they are genuine.
  • Eavesdropping. Anyone on the path can see which names you look up. DNS over HTTPS and DNS over TLS encrypt the conversation between your device and the resolver.
  • Hijacking. Attackers who gain control of a domain account or registrar can change records. Protect those accounts with strong authentication and registrar locks.
  • Amplification attacks. Poorly configured open resolvers can be abused to flood a victim with traffic, so resolvers should be restricted to their intended users.

Troubleshooting with simple tools

  • nslookup and dig let you query a name directly and choose which server to ask.
  • Comparing answers from different resolvers helps reveal stale caches or misconfigured servers.
  • Clearing your local DNS cache forces a fresh lookup, for example with ipconfig /flushdns on Windows.
  • If a name resolves but the site fails to load, the problem is probably beyond DNS, such as the server or firewall.
  • If a newly registered domain does not resolve, verify that the registrar lists the correct name servers.

Frequently Asked Questions

Why do DNS changes take time to appear everywhere?

Resolvers and devices keep cached copies of records until their TTL runs out. Until then, they will keep returning the old answer. Lowering the TTL a day or two before a planned change shortens the delay, and you can raise it again afterward.

Which DNS resolver should I use?

Your internet provider's default works for most people. Public resolvers are alternatives that may offer encryption features, filtering options or different performance. Consider speed, privacy practices and reliability, and remember that the resolver you choose can see the names you look up.

What is the difference between a domain registrar and a DNS host?

A registrar is where you register and renew a domain name. A DNS host runs the authoritative servers that publish the records. They can be the same company or different ones. The registrar tells the world which name servers are responsible, and those servers answer for the details.

Related reading