DNS
Domain Name System (DNS) Overview
The Domain Name System (DNS) is a hierarchical system used to translate human-friendly domain names (e.g., www.google.com) into machine-friendly IP addresses (e.g., 142.250.190.14). DNS is essential for internet functionality, allowing users to access websites and services without memorizing numerical IP addresses.
Key DNS Concepts
- Hostname
A hostname is a unique name assigned to a device on a network. It is the first part of a Fully Qualified Domain Name (FQDN).
- Example: In www.google.com, www is the hostname.
- Domain Name
A domain name is a human-readable identifier that maps to an IP address via DNS. It consists of multiple parts separated by dots.
- Example: google.com is a domain name.
- DNS Zone
A DNS zone is an administrative segment of the DNS namespace managed by a specific entity. A domain can be broken into zones for easier management.
- Example: example.com can have subdomains like blog.example.com and shop.example.com, each managed separately.
- Primary and Secondary DNS
- Primary DNS Server: The main server that holds the original zone file with DNS records.
- Secondary DNS Server: A backup that receives updates from the primary DNS and provides redundancy.
- Fully Qualified Domain Name (FQDN)
An FQDN is the complete domain name specifying its exact location in the DNS hierarchy. It includes the hostname and the full domain.
- Example: www.example.com. (The dot at the end represents the root of the DNS hierarchy.)
- DNS Hierarchy
DNS follows a hierarchical structure with multiple levels:
- Root Level (“.”) – The starting point of DNS (handled by root name servers).
- Top-Level Domain (TLD) – The highest domain category (e.g., .com, .org, .edu).
- Second-Level Domain (SLD) – The registered domain name (e.g., google in google.com).
- Subdomain – A division of a domain (e.g., mail.google.com).
- Host – A specific machine or service (e.g., www in www.example.com).
- DNS Port
- DNS primarily operates on UDP port 53 for quick, lightweight queries.
- TCP port 53 is used for larger DNS responses (e.g., zone transfers).
- DNS Queries
A DNS query is a request sent from a client to a DNS server to resolve a domain name to an IP address.
Types of DNS Queries
- Recursive Query – The DNS resolver performs all lookups until it finds the answer.
- Iterative Query – The DNS server responds with a referral to another server, requiring multiple steps.
- Inverse Query – Resolves an IP address to a domain name (reverse DNS lookup).
Types of DNS Records
- A Record – Maps a domain to an IPv4 address.
- AAAA Record – Maps a domain to an IPv6 address.
- CNAME Record – Creates an alias for another domain name.
- MX Record – Specifies mail servers for email delivery.
- PTR Record – Used for reverse DNS lookups.
- How DNS Works on the Internet
- User enters a URL (e.g., www.example.com) in a web browser.
- The request is sent to a DNS resolver (e.g., the ISP’s DNS server).
- If the resolver does not have the IP cached, it queries root name servers.
- The root directs the query to the TLD name server (e.g., .com servers).
- The TLD name server directs the query to the authoritative name server for example.com.
- The authoritative name server returns the IP address of www.example.com.
- The resolver caches the result and returns it to the user.
- The browser establishes a connection to the server hosting the website.
DNS Analogy: The Phonebook of the Internet
Imagine DNS as the phonebook of the internet:
- You (the user) want to call “Pizza Place”, but you don’t know its phone number.
- You look in the phonebook (DNS) to find “Pizza Place” (Domain Name).
- The phonebook gives you the phone number (IP Address).
- You dial the number, and your call connects to the restaurant (Website Server).
Just like a phonebook helps you find numbers instead of memorizing them, DNS helps translate domain names into IP addresses for easy internet navigation.