1 of 62

DNS

Domain Name System

2 of 62

DNS DOMAIN NAME SYSTEM

An application layer protocol defines how the application processes running on different systems, pass the messages to each other.

  • DNS stands for Domain Name System.
  • DNS is a directory service that provides a mapping between the name of a host on the network and its numerical address.
  • DNS is required for the functioning of the internet.
  • DNS is a service that translates the domain name into IP addresses. This allows the users of networks to utilize user-friendly names when looking for other hosts instead of remembering the IP addresses.

DNS is a TCP/IP protocol used on different platforms. The domain name space is divided into three different sections: generic domains, country domains, and inverse domain.

3 of 62

4 of 62

5 of 62

6 of 62

7 of 62

8 of 62

9 of 62

10 of 62

11 of 62

What is DNS Server

  • What it does:�DNS servers maintain a database that maps domain names to their corresponding IP addresses, allowing users to access websites using easy-to-remember names instead of complex numerical addresses.
  • How it works:�When you type a domain name into your browser, your computer first sends a request to a DNS server to find the IP address associated with that domain name.
  • Why it's important:�Without DNS, you would need to memorize the IP address of every website you want to visit, which would be extremely difficult and impractical.
  • Beyond websites:�DNS is also used for other internet services, including email (finding the mail server), video conferencing (connecting to servers), and online gaming (connecting to game servers).

12 of 62

13 of 62

14 of 62

Name Space

1.Flat

2.Hierarchical

15 of 62

Flat Name Space

Characteristics:

  • Names are simple and unstructured (no hierarchy).
  • Requires centralized control to prevent duplicates.
  • Works well for small networks but fails in large-scale systems.

Example 1: Local Network Devices

Suppose a small office has three computers:

  • Printer1 → 192.168.1.10
  • HR-PC → 192.168.1.20
  • FileServer → 192.168.1.30

Problem:

  • If another device tries to use Printer1, it causes a naming conflict.
  • A central admin must manually assign names to avoid duplication.

Example 2: Early Computer Networks (Before DNS)

  • In the 1970s, ARPANET used a flat hostname system (e.g., UCLA, MIT, SRI).
  • As more universities joined, name conflicts increased, making it unmanageable.

Why Flat Naming Fails for the Internet?

  • No scalability (millions of devices need unique names).
  • Single point of failure (central authority must approve every name).

16 of 62

Hierarchical Name Space

Characteristics:

  • Names are structured in levels (e.g., subdomain.domain.tld).
  • Decentralized control (different groups manage different parts).
  • Used in DNS (Domain Name System) for the Internet.

  • No conflicts because:
    • .com ensures no two companies have the same domain.
    • example.com controls its own subdomains (mail.example.com, ftp.example.com).
    • Example 2: Email Servers (mail.google.com)
  • .com → ICANN approves this TLD.
  • google → Google owns this domain.
  • mail → Google’s IT team assigns this to their email servers.

Part

Managed By

Purpose

.com

ICANN (Global Authority)

Top-Level Domain (TLD) for commercial sites

example

Domain Registrar (e.g., GoDaddy)

Organization/Company Name

www

Company’s IT Team

Specific server (e.g., web server)

17 of 62

Key Differences (Flat vs. Hierarchical)

Advantages of Hierarchical Naming:

Scalable (supports billions of names).�✅ Distributed control (no single authority needed).�✅ Avoids duplication (each level is unique).

Feature

Flat Name Space

Hierarchical Name Space

Structure

Single-level (Server1)

Multi-level (server.company.com)

Scalability

Only for small networks

Works for global systems (Internet)

Management

Centralized (one admin)

Decentralized (ICANN, registrars, companies)

Real-World Use

Old LAN systems

Modern DNS (Internet)

18 of 62

19 of 62

20 of 62

DOMAIN NAME SPACE

. (root)

|

-------------------

| | |

com edu org

| | |

google mit wikipedia

/ \ | |

mail drive cs en

1. The DNS Tree Structure (Inverted Tree)

Imagine an upside-down tree where:

  • The root is at the top (. or an empty string).
  • Branches are domain names (like .com, .org).
  • Leaves are specific websites (like google.com).
  • Root (.) → The very top (managed by ICANN
  • [ Internet Corporation for Assigned Names and Numbers ] ).
  • Top-Level Domains (TLDs).com, .edu, .org.
  • Second-Level Domainsgoogle.com, mit.edu.
  • Subdomainsmail.google.com, cs.mit.edu.

2. Key Rules of DNS

  1. Max 128 Levels (from root to the deepest subdomain).
  2. Each label ≤ 63 characters (e.g., google is 6 letters).
  3. Siblings must be unique (no two google.com).

21 of 62

22 of 62

3. Real-World Examples

Example 1: Normal Website (www.amazon.com)

  • www → Subdomain (web server).
  • amazon → Company name.
  • com → TLD (commercial).
  • (Root . is hidden).

Example 2: University Website (cs.harvard.edu)

  • cs → Computer Science dept.
  • harvard → University name.
  • edu → TLD (education).

Example 3: Country-Specific Site (bbc.co.uk)

  • bbc → British Broadcasting Corp.
  • co → Commercial (UK).
  • uk → Country TLD.

Example 4: Long Subdomain (shop.books.amazon.com)

  • shop.books → Book store section.
  • amazon → Company.
  • com → TLD.

Why This Structure?

No Name Conflicts (only one google.com).�✅ Easy to Manage (companies control their own subdomains).�✅ Fast Lookups (DNS searches level by level).

1. .com (Commercial)

  • Purpose:
    • Originally for commercial businesses (now used globally for any purpose).
  • Key Traits:
    • Most popular TLD (≈ 160 million registered domains).
    • No restrictions—anyone can register (e.g., google.com, amazon.com).
    • Operated by Verisign.
  • Example:
    • netflix.com (streaming service).

2. .edu (Education)

  • Purpose:
    • Exclusively for accredited educational institutions (mainly U.S. colleges/universities).
  • Key Traits:
    • Strict eligibility (requires U.S. Department of Education approval).
    • Managed by Educause.
    • Rarely used outside academia.
  • Example:
    • harvard.edu (Harvard University).

3. .uk (United Kingdom)

  • Purpose:
    • Country-code TLD (ccTLD) for the United Kingdom.
  • Key Traits:
    • Second-level domains often used (e.g., .co.uk, .ac.uk).
      • .co.uk → Businesses (e.g., bbc.co.uk).
      • .ac.uk → Academic institutions (e.g., cam.ac.uk for Cambridge).
    • Managed by Nominet.
  • Example:
    • gov.uk (UK government website).

23 of 62

24 of 62

25 of 62

Label

1. What is a Label?

  • A label is a string (text segment) assigned to each node in the DNS hierarchy.
  • Max length: 63 characters (e.g., google = 6 characters).
  • Allowed characters: Letters (a-z), digits (0-9), and hyphens (-), but not at the start/end.
  • Case-insensitive: Google.COM = google.com.

2. The Root Label

  • The topmost node (root) has an empty label (null string), represented by a dot . in FQDNs.
    • Example: In example.com., the trailing dot represents the root.

3. Label Uniqueness Rule

  • Sibling nodes (same parent) must have unique labels.
    • ✅ Valid: google.com and apple.com (different labels under .com).
    • ❌ Invalid: Two google.com entries under .com.

26 of 62

27 of 62

Domain Name

1. What is a Domain Name?

A domain name is a human-readable address that identifies a node in the DNS hierarchy. It is constructed as a sequence of labels separated by dots (.), read from left (specific) to right (general).

2. Structure of a Full Domain Name

  • Format: [label].[label].[...].[root]
    • Each label represents a level in the DNS tree.
    • The root is represented by an empty (null) label, denoted by a trailing dot (.).
  • Example:
    • mail.google.com. breaks down into:
      • mail (host/service)
      • google (organization)
      • com (top-level domain)
      • . (root, implied but often omitted)

28 of 62

Fully Qualified Domain Name [ FQDN ]

  • Definition: Complete absolute address ending with a dot (.)
  • Example: mail.google.com.
    • mail = host
    • google = domain
    • com = TLD
    • . = root
  • Used when: Precise location is needed globally

[host].[subdomain].[domain].[tld].

│ │ │ │ └── Root (null label, represented by .)

│ │ │ └── Top Level Domain (com, edu)

│ │ └── Second Level Domain (google, mit)

│ └── Subdomain (mail, www)

└── Host (server1, ns1)

29 of 62

Examples:

  1. mail.google.com.
    • mail = email server
    • google = company
    • com = top-level domain
    • . = root
  2. www.wikipedia.org.
    • www = web server
    • wikipedia = organization
    • org = TLD
    • . = root

When Used:

  • In DNS configurations (e.g., zone files).
  • When absolute precision is required (e.g., ping mail.google.com.).

1. Fully Qualified Domain Name (FQDN)

What it is:

  • The complete, absolute address of a device on the internet.
  • Always ends with a dot (.) to indicate the DNS root.

When to use it:�Global communication (e.g., accessing a public website).�✅ DNS configurations (e.g., zone files, dig commands).�✅ When precision is critical (e.g., connecting to a specific server).

Examples:

  • mail.google.com.
  • www.wikipedia.org.
  • ns1.cloudflare.com.

How it works:

  1. You type mail.google.com. in a DNS query.
  2. The resolver starts at the root (.), then .com, then google, then mail.
  3. Returns the exact IP address of Google’s mail server.

30 of 62

Partially Qualified Domain Name [ PQDN ]

Definition: An incomplete address without a trailing dot, resolved relative to the local domain.�Format: [host] or [host].[subdomain]�Key Point: The local DNS adds the missing parts.

Examples:

  1. Inside google.com:
    • drive → Resolves to drive.google.com.
    • calendar → Resolves to calendar.google.com.
  2. Inside university.edu:
    • library → Resolves to library.university.edu.

When Used:

  • Local networks (e.g., typing printer instead of printer.office.local).
  • Shortcuts in internal systems.

What it is:

  • A shortcut or relative address used within a local network.
  • No trailing dot — the local DNS adds the missing parts.

When to use it:�Local networks (e.g., office, school).�✅ Internal services (e.g., printers, intranet sites).�✅ Convenience (saves typing full names).

Examples:

  • Inside company.com:
    • printer → Resolves to printer.company.com.
    • hr → Resolves to hr.company.com.
  • Inside home.net:
    • nas → Resolves to nas.home.net.

How it works:

  1. You type printer on your office computer.
  2. The local DNS appends company.com. to create printer.company.com..
  3. Returns the IP of the office printer.

31 of 62

Why This Matters

  • FQDNs ensure accuracy across the entire internet.
  • PQDNs save time within private networks.
  • Mixing them up causes errors:
    • ❌ Using printer on the public internet → Fails (no global meaning).
    • ❌ Omitting the dot in a DNS config → Breaks resolution.

32 of 62

Examples

Email Server Scenario

1. Fully Qualified Domain Name (FQDN)

Real-world example:�mail.google.com. (the trailing dot matters!)

  • Why FQDN? When your email client needs to find Google's mail servers globally:
    • mail = specific mail server
    • google = organization
    • com = top-level domain
    • . = root (ensures lookup starts at DNS root)
  • How it's used:�When you send an email to someone@gmail.com, your computer performs a DNS lookup for the FQDN gmail-smtp-in.l.google.com. to find Google's mail servers.

Real-world example:�printer (in your office network)

  • Why PQDN? When you print at work:
    • You just type \\printer in Windows
    • Your office DNS automatically expands it to printer.office.local.
    • Resolves to your office printer's IP
  • Key difference:�If you tried printer at home, it would fail - it only works in your office network.

Practical Impact:

  • Your phone uses FQDNs to find websites
  • Your office network uses PQDNs for convenience

33 of 62

34 of 62

Distribution of the DNS Namespace

The Domain Name System (DNS) is distributed across countless servers worldwide to ensure efficiency, reliability, and scalability. Below is a structured breakdown of how this works:

1. Why Distribute DNS?

Problems with a Centralized System

  • ❌ Inefficiency – A single server handling all global DNS queries would be overwhelmed.
  • ❌ Unreliability – A crash or attack would take down the entire internet’s naming system.
  • ❌ Slow Response Times – Users far from the central server would experience delays.

Solution: A Distributed Hierarchy

DNS divides responsibility among root servers, TLD servers, and authoritative name servers, ensuring:

  • ✅ Load Balancing – No single server bears all the traffic.
  • ✅ Fault Tolerance – If one server fails, others can still resolve queries.
  • ✅ Faster Lookups – Servers closer to users handle requests.

35 of 62

Level

Server Type

Responsibility

Example

Root

Root DNS Servers (13 globally)

Redirect queries to TLD servers

Points .com queries to .com servers

Top-Level Domain (TLD)

TLD Servers (e.g., .com, .org)

Manage domain extensions

.com servers know where google.com is

Authoritative

Authoritative Name Servers

Store actual DNS records for domains

google.com’s servers manage mail.google.com

2. Hierarchy of DNS Servers

DNS is structured like an inverted tree, with different servers managing different levels:

36 of 62

37 of 62

38 of 62

39 of 62

40 of 62

41 of 62

42 of 62

43 of 62

44 of 62

45 of 62

46 of 62

47 of 62

48 of 62

Resolution, Resolver, and Iterative Resolution

1. DNS Resolution

What it is:�The process of translating a domain name (e.g., google.com) into an IP address (e.g., 142.250.190.46).

Example:

  • You type google.com → Your computer performs DNS resolution to find its IP (142.250.190.46).

Key Point:�Resolution is the overall task of converting names to IPs.

2. DNS Resolver

What it is:�The software (or server) that performs DNS resolution. It can work iteratively or recursively.

Types:

  • Stub Resolver: Basic resolver on your device (e.g., your laptop’s DNS client).
  • Recursive Resolver: Full-service resolver (e.g., your ISP’s DNS server).

Example:

  • Your laptop’s stub resolver asks your ISP’s recursive resolver: "What’s the IP of google.com?"

Key Point:�A resolver is the tool that does the work.

49 of 62

3. Iterative Resolution

What it is:�A resolution method where the resolver contacts multiple servers step-by-step, getting referrals until it finds the answer.

Steps (Example for mail.google.com):

  1. Resolver asks the Root Server: "Where’s mail.google.com?"�→ Root: "Ask a .com server."
  2. Resolver asks the .COM TLD Server.�→ .COM: "Ask Google’s authoritative server (ns1.google.com)."
  3. Resolver asks ns1.google.com.�→ Authoritative Server: "mail.google.com = 142.250.190.46."

Key Point:

  • The resolver does all the legwork.
  • Used by local resolvers (e.g., your router or ISP).

Term

Role

Example

Resolution

The process of finding an IP

Converting google.com142.250.190.46

Resolver

The tool that performs resolution

Your ISP’s DNS server (8.8.8.8)

Iterative Resolution

A method where the resolver queries servers step-by-step

Root → TLD → Authoritative (as above)

50 of 62

51 of 62

52 of 62

53 of 62

54 of 62

Example

+---------+ +------------+ +-------------+ +-------------------+

| Client | ----> | Root Server| ----> | .COM Server | ----> | Authoritative |

| (Your PC)| | (.) | | (TLD) | | Server (google.com)|

+---------+ +------------+ +-------------+ +-------------------+

1. Query 2. Referral 3. Referral 4. Final Answer

"mail.google.com" "Ask .com" "Ask ns1.google.com" "142.250.190.46"

55 of 62

56 of 62

57 of 62

58 of 62

TYPES OF RECORDS

Two types of records are used in DNS. The question records are used in the question section of the query and response messages. The resourcerecords are used in the answer, authoritative, and additional information sections of the response message.

Question Record A question record is used by the client to get information from a server. This contains the domain name.

Resource Record Each domain name (each node on the tree) is associated with a record called the resource record. The server database consists of resource records. Resource records are also what is returned by the server to the client.

59 of 62

DNS MESSAGES

Two Types of DNS Messages

  1. Query Message (Question from Client)
    • Sent by your device when you visit a website.
    • Contains: Header + Question Section.
  2. Response Message (Answer from Server)
    • Sent back by DNS servers.
    • Contains: Header + Question + Answer + Authority + Additional Sections.

+---------------------+

| Header | (12 bytes - controls the message)

+---------------------+

| Question(s) | (What you're asking - e.g., "Where is google.com?")

+---------------------+

| Answer(s) | (The reply - e.g., "google.com = 142.250.190.46")

+---------------------+

| Authority (NS) | (Which servers are authoritative for the domain)

+---------------------+

| Additional Info | (Extra helpful data, like IPs of authoritative servers)

+---------------------+

60 of 62

61 of 62

REGISTRARS

1. What is a Registrar?

  • A registrar is a company approved by ICANN (the organization that manages the internet’s domain system) to sell and register domain names.
  • Examples: GoDaddy, Namecheap, Google Domains.

2. Steps to Register a Domain

  1. Check Availability
    • You search for a domain (e.g., yourbusiness.com) on a registrar’s website.
    • The registrar checks if the name is unique (no one else owns it).
  2. Provide Server Info
    • You must give:
      • Domain name (e.g., ws.yourbusiness.com).
      • Server IP address (e.g., 200.200.200.5).
  3. Pay the Fee
    • Registrars charge a yearly fee (e.g.,
    • 10–
    • 10–20/year for .com).
  4. Added to DNS
    • The registrar updates the global DNS database so your domain works worldwide.

3. Example: Registering ws.wonderful.com

After payment, the registrar:

  1. Reserves wonderful.com (if available).
  2. Links ws.wonderful.com to 200.200.200.5 in DNS.
  3. Now, anyone typing ws.wonderful.com will reach your server!

4. Key Notes

  • ICANN oversees registrars to prevent fraud.
  • Domains expire if you don’t renew them (others can buy them!).
  • Need a server? You can rent one from hosting providers (e.g., AWS, Bluehost).

🚀 TL;DR:

  1. Pick a name → 2. Pay a registrar → 3. Connect it to your server → 4. It goes live!

What You Provide

Example Value

Domain Name

ws.wonderful.com

Server IP Address

200.200.200.5

62 of 62