How DNS turns names into addresses

What happens between typing a domain and reaching a server, the six record types worth knowing, why changes take time to arrive, how to look records up yourself, common mistakes and a short quiz.

Guide45 minBachelor +2CC BY 4.0

What you will learn

  • Describe a DNS lookup step by step
  • Name what A, AAAA, CNAME, MX, TXT and NS records hold
  • Explain what a TTL is and why DNS changes are not instant
  • Look up records for a real domain with nslookup

Computers find each other by numbers. People prefer names. DNS, the Domain Name System, translates between the two, millions of times a second, without anyone noticing.

It works like the contacts app on a phone. You tap "Anna", and the phone looks up her number. You type a domain, and DNS looks up the server's address. The difference: no single computer holds the whole internet's list. It is spread over many servers, each responsible for its own part.

What a domain name is made of

Read a name from right to left. In www.northwind.example:

  • example is the top-level domain (TLD), like .com, .de or .uk. (.example is reserved for teaching, so it never belongs to a real company.)

  • northwind is the name an organisation registers under that TLD.

  • www is a subdomain the organisation sets up itself. It could just as well be shop or mail.

One lookup, step by step

Put in order

One lookup, step by step

  1. 1Those servers answer with the address
  2. 2The browser connects to that address
  3. 3The resolver passes the address back and remembers it for a while
  4. 4It asks its resolver, usually run by your internet provider or your network
  5. 5The resolver asks a root server who handles .com
  6. 6The .com servers name the servers responsible for example.com
  7. 7The computer checks its own memory and finds no saved answer
  8. 8You type example.com and press Enter

The parts in this chain have names:

  • The resolver does the asking on your behalf. Your home router, school network or internet provider tells your device which resolver to use. Some people choose a public resolver instead.

  • The root servers are the top of the system. They do not know any addresses of websites, only who runs each top-level domain. There are 13 named root server identities, each copied to many places around the world.

  • The TLD servers know who is responsible for each domain under their ending.

  • The authoritative name servers hold the domain's actual records. They are the ones listed in the domain's NS records.

Most lookups never go all the way up. Your computer, your router and the resolver all remember recent answers, so the second visit to a site is answered from memory in a fraction of a second.

The records worth knowing

Record

What it holds

Example value

A

An IPv4 address

203.0.113.10

AAAA

An IPv6 address

2001:db8::10

CNAME

Another name this one is an alias for

shop.example.net

MX

The servers that receive email

10 mail.example.com

TXT

Text, such as SPF rules or ownership proofs

v=spf1 include:... ~all

NS

The servers responsible for the domain

ns1.example.com

The example addresses come from ranges reserved for documentation, so they never point at a real server.

  • A and AAAA are the most common records. IPv4 addresses like 203.0.113.10 have run short, so newer IPv6 addresses (AAAA, "quad A") are much longer. Many domains have both.

  • CNAME says "this name is another name". If www.northwind.example is a CNAME for northwind.example, the resolver looks up the second name and uses its address. A name with a CNAME cannot have any other records, which is why the bare domain itself usually cannot be a CNAME.

  • MX records come with a number, the priority. Lower numbers are tried first: a server with priority 10 is preferred over one with 20, which acts as a backup. An MX record must name a server, not an IP address.

  • TXT records hold text for other systems to read. Email security records live here (see the guide to SPF, DKIM and DMARC), and many online services ask you to add a TXT value to prove that you own a domain.

  • NS records name the authoritative servers. Changing them moves the whole domain to another DNS provider.

Good to know as well: PTR records work the other way round and turn an IP address back into a name (mail servers check them), and CAA records say which certificate authorities may issue HTTPS certificates for the domain.

Why changes take time: the TTL

Every record has a TTL (time to live), in seconds. It tells resolvers how long they may keep the answer before asking again.

Worked example: Northwind's A record has a TTL of 3600 seconds, which is one hour. At 10:00 the company moves its website to a new server and changes the A record. A resolver that looked up the name at 9:55 keeps the old address until 10:55. Some visitors reach the new server at once, others only up to an hour later. With a TTL of 86,400 seconds (one day), the change could take a day to reach everyone.

This is what people mean when they say a DNS change "takes time to propagate". Nothing travels; old copies simply expire. Before a planned move, administrators lower the TTL a day in advance, so the switch itself spreads quickly.

Look it up yourself

On Windows, macOS and Linux, a terminal can ask DNS directly with nslookup.

Ask for the mail servers of a domain
nslookup -type=MX example.com
Other questions you can ask
nslookup example.com
nslookup -type=AAAA example.com
nslookup -type=TXT example.com
nslookup -type=NS example.com

On macOS and Linux, dig example.com MX gives the same answer with more detail, including the TTL. For MX records without a terminal, use the Mailbox Provider Checker, which looks up the MX records and names the provider behind them.

When you read the output, look for three things: the server that answered (your resolver), whether the answer is "non-authoritative" (it came from a cache, which is normal), and the records themselves.

Common mistakes

  • Expecting changes to show at once. Old answers stay in caches until their TTL runs out.

  • Mixing up three different services. The registrar is where the domain was bought, the DNS host answers the lookups, and the web host runs the website. They can be three different companies.

  • A CNAME on the bare domain. It clashes with the NS and other records the domain needs. Use an A record there, or a special alias feature of the DNS host.

  • An MX record that points to an IP address. It must name a server, which then has its own A or AAAA record.

  • Two SPF records. A domain may have only one TXT record that starts with v=spf1; with two, the check fails.

  • Blaming DNS for everything. If one site does not load but others do, the problem is more often the site than DNS.

Is DNS private and safe?

Classic DNS questions travel unencrypted, so the network you use can see which names you look up. Many browsers and systems can now send lookups encrypted (DNS over HTTPS). A separate extension, DNSSEC, lets a domain sign its records so resolvers can detect forged answers. Not every domain uses it.

Quiz

Check yourself

7 questions
  1. 1.What does a resolver do?

  2. 2.What do the root servers know?

  3. 3.A domain has two MX records: priority 10 and priority 20. Which server is tried first?

  4. 4.An A record has a TTL of 3600. What does it mean?

  5. 5.A company changes its A record. Why do some visitors still reach the old server for a while?

  6. 6.Which record would you look up to find out who receives email for a domain?

  7. 7.Where do email security rules such as SPF live in DNS?

Practise the record types with the DNS record types exercise.

Reuse this material

CC BY 4.0

You may copy, adapt and share it, also commercially, as long as you credit ManyPI and link back.

"How DNS turns names into addresses" by ManyPI (https://manypi.com/edu/dns-explained), licensed under CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)