3 minute read

What is DNS?

The Domain Name System (DNS) is a distributed system that translates human-readable domain names into IP addresses.

For example, it is much easier to remember www.example.com than 192.0.2.10.

When we enter a domain name into our browser, DNS finds the corresponding IP address so our computer knows where to send the request.

Why Do We Need DNS?

Every device connected to a network is identified by an IP address. Computers communicate using IP addresses, not domain names.

Without DNS, users would have to remember IP addresses for every website they visit.

DNS Terminologies

Domain Name

A domain name is the human-readable name of a website.

Example:

example.com
amazon.com
google.com

Fully Qualified Domain Name (FQDN)

A Fully Qualified Domain Name (FQDN) specifies the complete path to a host.

Example:

www.example.com

www      → Hostname
example  → Second-Level Domain
com      → Top-Level Domain

Hostname

A hostname identifies a specific device or service within a domain.

Example:

www.example.com
api.example.com
mail.example.com

Here,

  • www
  • api
  • mail

Top-Level Domain (TLD)

The Top-Level Domain is the last part of a domain name.

Example:

.com
.org
.net
.io
.dev

DNS Resolver

A DNS Resolver is the first DNS server contacted by our device.

Its job is to find the correct IP address on our behalf.

Most users automatically use a resolver provided by:

  • Their Internet Service Provider (ISP)
  • Google Public DNS (8.8.8.8)
  • Cloudflare DNS (1.1.1.1)
  • Amazon Route 53 Resolver (inside AWS VPCs)

Authoritative Name Server

An Authoritative Name Server stores the official DNS records for a domain.

Example:

example.com

Its authoritative server knows that:

www.example.com
↓

203.0.113.15

This is considered the final and trusted answer.

How DNS Works

Suppose a user visits www.example.com, the DNS lookup process is as follows:

Step 1 — User Requests the Website

The browser asks the operating system for the IP address of www.example.com

Step 2 — Check Local Cache

The operating system first checks whether it already knows the IP address.

If found, the process stops immediately.

Otherwise, it queries a DNS resolver.

Step 3 — DNS Resolver

The resolver begins searching for the answer.

If it has the answer cached, it immediately returns the IP address.

Otherwise, it performs a recursive lookup.

Step 4 — Root Name Server

The resolver contacts a Root DNS Server.

The root server doesn’t know the IP address, but it knows where the appropriate Top-Level Domain (TLD) servers are.

For example:

www.example.com

↓

Root Server

↓

".com" Name Server

Step 5 — TLD Name Server

The .com name server knows which authoritative server manages example.com, it responds with the authoritative name server.

Step 6 — Authoritative Name Server

The resolver asks:

What is the IP address of:

www.example.com?

The authoritative server replies 203.0.113.15.

Step 7 — Return the IP Address

The resolver returns the IP address to the browser.

The browser can now establish a connection to:

203.0.113.15

and load the website.

DNS Flow Lookup

User
 │
 ▼
Browser
 │
 ▼
Local DNS Cache
 │
 ▼
DNS Resolver
 │
 ▼
Root Name Server
 │
 ▼
TLD Name Server (.com)
 │
 ▼
Authoritative Name Server
 │
 ▼
Returns:
203.0.113.15
 │
 ▼
Browser connects to Web Server

Common DNS Record Types

A DNS record maps a domain name to specific information.

Record Purpose Example
A Maps a domain to an IPv4 address. example.com → 203.0.113.10
AAAA Maps a domain to an IPv6 address. example.com → 2001:db8::1
CNAME Creates an alias to another domain name. www.example.com → example.com
MX Specifies the mail server for a domain. mail.example.com
TXT Stores arbitrary text, commonly used for domain verification and email security (SPF, DKIM, DMARC). Verification tokens
NS Specifies the authoritative name servers for a domain. ns-123.awsdns.com

Route 53