Domain Name System (DNS) is an Application Layer protocol running over UDP/TCP Port 53. It functions as the phonebook of the internet, translating human-friendly Fully Qualified Domain Names (FQDNs), such as app.example.com, into machine-routable IPv4 addresses (e.g., 198.51.100.75) or IPv6 addresses.
Recursive vs. Iterative DNS Queries
Recursive Query: The client demands a complete answer from the DNS Resolver ("Give me the IP or tell me it doesn't exist"). The Resolver assumes full responsibility to fetch the IP address on behalf of the client.
Iterative Query: The client or DNS Resolver queries servers step-by-step. If a server does not hold the answer, it returns a referral to the next authoritative server in the hierarchy (Root $\rightarrow$ TLD $\rightarrow$ Authoritative Server).
The Hierarchy of DNS Name Servers
1. DNS Client / Local Cache: Checks local OS cache (`hosts` file or browser cache) prior to issuing network queries.
2. Recursive Resolver (e.g., ISP / 8.8.8.8 / 1.1.1.1): Receives client requests and queries root and TLD servers iteratively to build the final answer.
3. Root Name Servers (.): Directs queries to the appropriate Top-Level Domain (TLD) servers based on suffix (e.g., `.com`, `.org`, `.net`).
4. TLD Name Servers (.com): Manages domain extensions and redirects queries to the domain's Authoritative Name Server.
5. Authoritative Name Server (example.com): Holds the actual DNS resource records (A, AAAA, CNAME, MX) and returns the final destination IP.
Essential DNS Resource Record Types
A Record: Maps a domain name to an IPv4 address (e.g., app.example.com $\rightarrow$ 198.51.100.75).
AAAA Record: Maps a domain name to an IPv6 address.
CNAME Record: Canonical Name; creates an alias mapping one domain name to another domain name.
MX Record: Mail Exchange; specifies the mail servers responsible for receiving email for the domain.
NS Record: Identifies the authoritative Name Servers for the domain zone.
PTR Record: Reverse DNS lookup; maps an IP address back to a domain name.