Understanding the Domain Name System

Oct 5, 2024

Domain Name System (DNS) Lecture Notes

Introduction to DNS

  • DNS stands for Domain Name System.
  • It is a directory service for name resolution, crucial for web browsing.
  • When you enter a hostname (e.g., www.uio.no), the browser needs an IP address to create a TCP/IP connection.

Key Features of DNS

  • Supports various types of names:
    • Real names (e.g., server01, Aragon)
    • Logical names (e.g., www.uio.no)
  • Supports different services:
    • Address resolution (A records for web)
    • Mail exchange (MX records for email)
  • Must support multiple address formats (IPv4 and growing IPv6).
  • Needs to be a distributed database due to the large number of servers and IoT devices.
  • Utilizes caching mechanisms for performance.

Structure of DNS

  • Defined in RFCs (old standards from 1987).
  • The domain namespace is structured like a tree:
    • Root node (no name)
    • Top-level domains (TLDs): e.g., .com, .no
    • Labels must be 1 to 63 bytes long.
    • Unique labels under the same parent.

Domain Name Terminology

  • Domain Name: A dot-separated sequence of labels (e.g., www.uio.no).
  • Subdomain: Part of the domain structure (e.g., medicine.uio.no).
  • Zone: A portion of the DNS namespace administratively defined, includes all associated names.

Top-Level Domains (TLDs)

  • Two types:
    • Country Code TLDs: (e.g., .no for Norway, .de for Germany).
    • Generic TLDs: (e.g., .com, .org, .edu).
  • New generic TLDs have been introduced (e.g., .google, .berlin).
  • Non-ASCII characters are now allowed in TLDs.

Name Servers and Zones

  • Each zone has at least two name servers (primary and secondary for backup).
  • Root Name Servers: 13 logical servers managing TLD servers.
  • Each zone has authoritative data and glue records for sub-zones.

Resource Records (RR)

  • Format:
    1. Owner (domain name)
    2. Type (e.g., A for IPv4, AAAA for IPv6, CNAME for aliases)
    3. Class (usually IN for Internet)
    4. Time to Live (TTL)
    5. Data (actual address or hostname)

Common Resource Record Types

  • A Record: Maps a hostname to an IPv4 address.
  • AAAA Record: Maps a hostname to an IPv6 address.
  • CNAME Record: Canonical name, alias for another domain.
  • MX Record: Mail exchange server for email delivery.
  • TXT Record: Arbitrary text, often for verification or policy information.
  • PTR Record: Used for reverse lookups.

The DNS Resolution Process

  1. The application (e.g., browser) calls the resolver to obtain an IP address.
  2. If the address is cached, it is returned immediately.
  3. If not cached, the resolver queries the configured name server.
  4. Recursive Resolution: Client asks for the final result; server handles all queries.
  5. Iterative Resolution: Server responds with responses to further queries.

Iterative Resolution Example

  • Example request flow:
    1. Request from client to the root server (e.g., www.mutnut.uio.no).
    2. Root server directs to TLD server (.no).
    3. TLD server directs to authoritative server (uio.no).
    4. Final authoritative server responds with the IP address.

DNS Caching

  • Caches responses in both local systems and name servers.
  • Improves performance by avoiding repetitive queries.
  • TTL indicates how long a record remains cached before being refreshed.

DNS Protocol Overview

  • Uses UDP primarily for requests (port 53); TCP for certain cases.
  • Query format includes flags (query or response, recursive desired).
  • Responses contain the original question and answers.

DNS Query/Response Example

  • Typical query: Asking for www.facebook.com's IP address.
  • Response includes:
    • CNAME record (alias)
    • A record (actual IP address)

Conclusion

  • Understanding DNS is crucial for network communication and web functionality.
  • DNS involves various components like name servers, resource records, and caching mechanisms to efficiently resolve domain names.