optional · CSS study notes
DNS (Domain Name System)
🧭
On this page — click any heading below to jump straight to it. ⬅️ Back to P-II.II. Computer Communications & Networks
OSI Layer: Application Layer (L7)
Definition
DNS (Domain Name System) is a distributed, hierarchical naming system that translates human-readable domain names (e.g., www.example.com) into numerical IP addresses that routers and hosts actually use to deliver packets. It is one of the Internet's core application-layer services — a directory that nearly every other application relies on.
Why DNS Is Needed
- IP addresses are hard for humans to remember and can change (server migration, load balancing) without the domain name changing
- Centralizing all name lookups at one server would be a single point of failure and a performance bottleneck at Internet scale — DNS instead distributes load across a worldwide hierarchy of servers
DNS Hierarchy (Distributed Database)
- Root DNS servers — top of the hierarchy (13 logical root server clusters worldwide), point to the correct TLD server
- TLD (Top-Level Domain) servers — handle domains like
.com,.org,.pk,.edu - Authoritative DNS servers — hold the actual DNS records for a specific domain (e.g., a university's own DNS server for
nust.edu.pk) - Local/recursive DNS server (resolver) — typically run by an ISP; the first point of contact for a client's query, resolving it on the client's behalf by walking the hierarchy
Query Types
- Recursive query — client asks the resolver for a final answer; the resolver does all the work of contacting root → TLD → authoritative servers itself
- Iterative query — each server responds with a referral to the next server to ask, rather than doing the lookup itself; used between the resolver and the upstream root/TLD/authoritative servers
- Caching — every DNS server (and often the client OS) caches responses for a TTL (time-to-live) period, dramatically reducing repeated lookups and root/TLD server load
Common Record Types
| Record | Purpose |
|---|---|
| A | Maps a hostname to an IPv4 address |
| AAAA | Maps a hostname to an IPv6 address |
| CNAME | Alias — one hostname points to another hostname |
| MX | Mail exchange — identifies the mail server for a domain |
| NS | Identifies the authoritative name server for a domain |
DNS and UDP
DNS primarily uses UDP (port 53) for its lookups, since queries/responses are small and a fast, low-overhead exchange matters more than guaranteed delivery (the resolver simply retries on timeout); DNS uses TCP for zone transfers and can retry over TCP when a UDP response is truncated. Modern DNS can also use encrypted transports; UDP is not its only query transport.
CSS Exam Angle
- A very likely question: "Explain the DNS hierarchy with a diagram" — draw Root → TLD → Authoritative, with the local resolver querying each in turn
- Be ready to justify why DNS uses UDP rather than TCP for ordinary lookups
- Tie DNS into "naming" as a Special Topic — it is the Internet's core naming/directory service, distinct from IP addressing itself
Example
Typing "css.gov.pk" into a browser triggers a DNS lookup: the local resolver (often the ISP's) checks its cache first; if absent, it queries a root server for the ".pk" TLD server, then the ".pk" server for the authoritative server of "gov.pk", and finally that authoritative server returns the actual IP address — all before the browser can even send its first HTTP request.
Likely Questions
- Explain the DNS hierarchy (root, TLD, authoritative, local resolver) with a diagram.
- Differentiate recursive and iterative DNS queries.
- Why does DNS primarily use UDP instead of TCP?
- List and explain common DNS record types (A, CNAME, MX, NS).
- Explain DNS caching and its role in reducing Internet-wide lookup load.
📜 Past-Paper Questions & Structured Answers
Questions are paraphrased; answer focus is suggested guidance, not an official marking scheme.
2025 · Paper-II · Q3(a)(i) · 2 marks
Question (paraphrased): Can web and mail services share a domain name, and which DNS record names its mail server?
Answer focus: Yes, explain separate record purposes and identify MX.
Yes. A domain can have an A/AAAA record pointing to its web server and an MX (Mail Exchange) record naming its mail server.
Example: example.org A → 192.0.2.10; example.org MX → mail.example.org; mail.example.org A → 192.0.2.20. The required record type is MX.
Precision: “alias” here means a shared service name informally. A literal DNS CNAME at a name generally cannot coexist with MX or other ordinary records at that same name; use A/AAAA plus MX for this example.
The remaining 2025 Q3(a) parts are placed with their own topics: ISP/edge/core diagram (3 marks) in Overview of Networking; FIFO queueing calculation (3 marks) in Network Devices; TCP choice (2 marks) in FTP (File Transfer Protocol) and Email — SMTP, POP3 & IMAP. The complete question totals 10 marks; DNS itself carries only 2.
Related: 2020 Paper-I Q3(a) includes DNS port 53, using UDP or TCP; see Servers, Server Types & Protocol Stack.