DNS (Domain Name System)

Every device connected to the Internet is identified by an IP address. However, IP addresses are difficult for humans to remember and may change over time. DNS (Domain Name System) provides a human-readable naming system (domain name) that maps a domain name to its corresponding IP address.

Instead of accessing

https://203.0.113.5

users simply access

https://example.com

The browser first resolves the domain name into an IP address before establishing the network connection.

DNS Resolution

A typical DNS lookup follows the process below.

Browser
    |
    | Check local DNS cache
    v
Operating System
    |
    | Check OS cache
    v
Recursive DNS Resolver
    |
    | Query Root DNS
    v
Root DNS Server
    |
    | Refer to .com TLD
    v
TLD DNS Server
    |
    | Refer to authoritative DNS
    v
Authoritative DNS Server
    |
    | example.com → 203.0.113.5
    v
Browser

Once the IP address is obtained, the browser can establish a TCP (or QUIC) connection to the destination server. Note that a domain name can corresponds to mulitple IPs.

Common DNS Records

RecordPurpose
AMaps a domain name to an IPv4 address
AAAAMaps a domain name to an IPv6 address
CNAMECreates an alias to another domain
MXSpecifies mail servers
TXTStores arbitrary text (e.g., domain verification, SPF, DKIM)

A Record

An A record directly maps a domain name to an IPv4 address.

example.com
       A Record
example.com  ---------------->  203.0.113.10

Example:

example.com    A    203.0.113.10

The returned IP address is then used to establish a TCP connection.

Browser
    |
    | DNS Query (example.com)
    v
DNS Server
    |
    | 203.0.113.10
    v
TCP Connection

However, A records require manual updates when the IP address changes.

CNAME Record

A CNAME (Canonical Name) record maps a domain name to another domain name instead of directly mapping to an IP address.

www.example.com
        CNAME
www.example.com  ------------>  example.com
                                    |
                                    v
                               203.0.113.10

Example:

example.com        A       203.0.113.10
www.example.com    CNAME   example.com

The advantage is that the underlying IP address can change without updating every related domain.


Comparison of A Record and CNAME Record

Modern cloud services, CDNs, and load balancers often provide a hostname instead of a fixed IP address.

myapp.com

     CNAME

cloud-load-balancer.example.com
                 |
                 v
          Managed IP pool

The service provider can change the underlying infrastructure while keeping the domain configuration unchanged.

Common use cases for DNS

  • Human-readable domain names
  • Decoupling domain names from changing IP addresses
  • Routing traffic to different services
  • Supporting email and domain verification

Query a DNS Server to Resolve the Domain Name

dig @8.8.8.8 www.bime.ntu.edu.tw

CDN (Content Delivery Network)

DNS determines where a service is located, but it does not improve how quickly content is delivered. A Content Delivery Network (CDN) is a geographically distributed network of servers that caches content closer to end users, reducing latency and improving availability. Note that it is the domain owner decides to use a CDN by configuring DNS to point the domain to the CDN provider (or by delegating DNS authority to the CDN provider).

Instead of every user contacting the origin server directly,

Users
    |
    v
Origin Server (Taiwan)

users are redirected to a nearby edge location.

             Origin Server
                 (Taiwan)
                     |
         +-----------+-----------+
         |           |           |
         v           v           v
      Tokyo      Singapore      Los Angeles
       Edge          Edge            Edge

The edge server serves cached content whenever possible, reducing both response time and the load on the origin server.

Typical Request Flow

Client
    |
    v
CDN Edge Server
    |
    | Cache Hit?
    |
    +------ Yes -------> Return cached content
    |
    No
    |
    v
Origin Server
    |
    v
Return response
    |
    v
Store in cache

What Can Be Cached?

Static resources are typically cached. For instance,

  • HTML pages
  • CSS
  • JavaScript
  • Images
  • Fonts
  • Videos

Dynamic requests usually bypass the cache. For instance,

  • User login
  • Payment processing
  • Database queries
  • Personalized content

Common use cases

  • Reducing latency
  • Lowering origin server load
  • Improving scalability
  • Increasing service availability
  • Mitigating DDoS attacks (when integrated with edge platforms)

Comparison between DNS vs CDN

Although DNS and CDN are frequently provided by the same platform (e.g., Cloudflare), they solve different problems.

DNSCDN
Primary purposeResolve domain namesDeliver content efficiently
Main functionDomain → IP mappingCache and distribute content
HappensBefore the connectionAfter the connection is established
Operates onDNS queriesHTTP/HTTPS traffic
Typical outputIP addressCached or origin response

Typical Modern Deployment

In modern web applications, DNS and CDN are often deployed together.

                  Client
                     |
                     |
               DNS Resolution
                     |
                     v
               CDN Edge Server
                     |
         +-----------+-----------+
         |                       |
         | Cache Hit             | Cache Miss
         |                       |
         v                       v
    Cached Content         Reverse Proxy
                                 |
                        +--------+--------+
                        |                 |
                    Frontend         Backend API
                                           |
                                           |
                                       Database
  • DNS translates the domain name into a reachable service address.
  • The CDN serves cached content whenever possible.
  • Cache misses are forwarded to the origin infrastructure.
  • The reverse proxy routes requests to the appropriate backend service.

Cloudflare

Cloudflare is a globally distributed edge network that combines DNS, CDN, and reverse proxy functions.

Instead of pointing a domain directly to the origin server, the domain owner configures DNS to point to Cloudflare. Users then connect to a nearby Cloudflare edge server, which can serve cached content or forward requests to the origin server.

                    User
                      |
                      |
              DNS Resolution
                      |
                      v
              Cloudflare Edge
          (CDN + Reverse Proxy)
                      |
          +-----------+-----------+
          |                       |
     Cache Hit              Cache Miss
          |                       |
          v                       v
 Cached Content            Origin Server

Cloudflare provides:

  • DNS resolution: maps domain names to Cloudflare’s edge network
  • CDN caching: serves static content from nearby edge locations
  • Reverse proxying: forwards dynamic requests to the origin server
  • Security services: TLS termination, DDoS protection, and web application firewall (WAF)

The user only interacts with Cloudflare’s edge servers and does not directly access the origin infrastructure.

Related articles

Network Interfaces and IP Address Fundamentals

A Network Interface is the connection point between a computer and a network. It is the operating system's abstraction of a network adapter, allowing applications to send and receive network traffi…

Training

HTTP Protocol (HyperText Transfer Protocol)

Defines how clients (e.g., browsers) and servers communicate using a stateless request–response model. HTTP is an application-layer protocol that runs on top of TCP. HTTP follows a simple cycle: A …

Training

Transport Layer Security (TLS)

TLS is a cryptographic protocol used to secure communication over a network. It is most commonly used in HTTPS, where it encrypts data between a client (browser) and a server. TLS ensures that data…

Training