onse
Distributed Systems

DNS

Domain Name System (DNS)

The Domain Name System (DNS) is the internet's phone book. It translates human-friendly names such as onsoftware.engineering into IP addresses such as 203.0.113.42.

1. The basic idea

When you enter:

https://onsoftware.engineering

your computer needs to discover the server's IP address before it can connect.

DNS therefore sits before the actual HTTP connection.


2. What happens when you type a URL?

Typically:

  1. The browser checks its DNS cache.
  2. The operating system checks its DNS cache.
  3. The configured DNS resolver is queried.
  4. If the resolver doesn't already know the answer, it performs a DNS lookup.
  5. The resolver eventually obtains the IP address.
  6. The result is cached for a period of time.
  7. The browser connects to the IP address.
Browser
   |
   v
OS DNS cache
   |
   v
DNS Resolver
   |
   +-- Root DNS server
   |
   +-- .engineering DNS server
   |
   +-- Authoritative DNS server
             |
             v
       203.0.113.42

3. The four important DNS players

1. DNS client

Usually your operating system or browser.

It asks:

"What IP address belongs to this domain?"

2. Recursive resolver

The resolver does the work on your behalf.

Examples include:

  • Your ISP's DNS resolver
  • Google Public DNS
  • Cloudflare DNS
  • A corporate DNS resolver

The client normally talks only to the resolver.

3. Root DNS servers

The root system doesn't normally know the IP address of your website.

Instead, it knows who is responsible for each top-level domain (TLD).

For example:

.                       <- root
+-- engineering         <- TLD

4. Authoritative DNS server

This is the final authority for a domain.

It contains records such as:

onsoftware.engineering -> 203.0.113.42

4. How recursive resolution works

Suppose the resolver receives:

What is the IP address of www.example.com?

It can work down the DNS hierarchy:

The important point is that the resolver performs the recursion.

Your computer doesn't normally contact all these servers itself.


5. DNS is hierarchical

DNS names form a hierarchy from right to left:

www.onsoftware.engineering
|   |          |
|   |          +-- Top-level domain
|   +------------- Domain
+------------------ Subdomain / host

More precisely:

www.onsoftware.engineering.
                         ^
                       root

The final . represents the DNS root, although it is normally omitted.


6. DNS records

DNS isn't just about IP addresses. A domain can have many different types of records.

RecordPurposeExample
AIPv4 address93.184.216.34
AAAAIPv6 address2001:db8::1
CNAMEAliaswww -> example.com
MXMail servermail.example.com
TXTArbitrary textSPF/DKIM verification
NSAuthoritative name serverns1.example.com
CAAAllowed certificate authoritiesletsencrypt.org

For example:

example.com

A       -> 93.184.216.34
MX      -> mail.example.com
CNAME   -> www.example.com

7. Why DNS is fast

DNS would be painfully slow if every request required a complete lookup.

Instead, DNS uses caching.

A response has a TTL (Time To Live):

example.com
A
93.184.216.34
TTL = 3600 seconds

The resolver can cache the answer for one hour.

During that time:

Client --> Resolver
             |
             +-- cached answer

No root, TLD, or authoritative server needs to be contacted.


8. DNS and changing IP addresses

Suppose your server moves:

Old server
203.0.113.42
       |
       v
New server
198.51.100.17

You change the A record:

example.com -> 198.51.100.17

But clients may continue receiving the old address until their cached DNS entry expires.

That's why DNS changes are not necessarily instantaneous.


9. DNS over UDP and TCP

Traditional DNS usually uses:

UDP port 53

TCP port 53 is also used when necessary, for example for larger responses or certain DNS operations.

Modern encrypted alternatives include:

  • DoH — DNS over HTTPS
  • DoT — DNS over TLS

These encrypt the DNS traffic between the client and resolver.


10. The whole picture

Putting everything together:

The key distinction is:

DNS finds the server. HTTP/HTTPS talks to the server.


11. The mental model

You can think of DNS like a chain of directories:

"What is onsoftware.engineering?"

        |
        v

Root
"Who handles .engineering?"

        |
        v

TLD
"Who handles onsoftware.engineering?"

        |
        v

Authoritative DNS
"The address is 203.0.113.42"

        |
        v

Browser
"Now I can connect."

Once you understand recursive resolvers, DNS hierarchy, authoritative servers, records, and caching, most of DNS becomes straightforward.

On this page