Domain Name System (DNS) (OCR A-Level Computer Science): Revision Notes
Domain Name System (DNS)
Overview
The Domain Name System (DNS) is a foundational part of the internet. It converts human-readable domain names, like www.example.com, into IP addresses, like 192.0.2.1, which computers use to locate and communicate with each other. Without DNS, we would have to remember complex IP addresses for each website we visit. DNS makes the internet more user-friendly by allowing us to use easy-to-remember domain names.
What is DNS?
- DNS is essentially the internet's "phonebook," enabling us to look up websites by name rather than by IP address.
- When you enter a URL (Uniform Resource Locator) in a browser, DNS translates this URL into an IP address so that your device can locate the correct server.
DNS Structure and Hierarchy
The DNS is structured hierarchically, with different levels of servers that handle various parts of the DNS lookup:
- Root DNS Servers: These are the highest level of DNS servers and manage requests for Top-Level Domains (TLDs), like .com, .org, and .UK.
- TLD DNS Servers: These servers manage specific TLDs. For example, a .com TLD server would handle all .com domain requests.
- Authoritative DNS Servers: These hold the actual IP addresses for domains. For instance, the authoritative DNS server for example.com will return the IP address associated with it.
How DNS Works: The Lookup Process
When you type a domain name into your browser, your computer performs a DNS query to find the IP address.
Steps of a DNS Lookup:
- Check Local Cache: Your device first checks if it has the IP address for the domain cached from a previous visit.
- Query Recursive Resolver: If the address isn't in your cache, the query goes to a recursive DNS resolver (often provided by your ISP or a DNS service like Google DNS).
- Root Server Contact: If the recursive resolver doesn't know the IP address, it contacts a Root DNS Server, which points it to the relevant TLD server.
- TLD Server Contact: The recursive resolver then queries the appropriate TLD server, which points it to the authoritative DNS server for the domain.
- Authoritative DNS Server Contact: Finally, the recursive resolver queries the authoritative DNS server for the domain, retrieving the IP address and returning it to your device.
- Connecting to the IP Address: Now that your device has the IP address, it can contact the web server to load the website.
Types of DNS Records
- DNS records store various information for a domain. Key types include:
- A Record: Maps a domain name to an IPv4 address.
- AAAA Record: Maps a domain name to an IPv6 address.
- CNAME Record: Points one domain name to another, useful for subdomains.
- MX Record: Specifies the mail server responsible for email for the domain.
Examples
Simple DNS Lookup Example: Imagine you enter www.example.com into a browser. Here's how DNS would resolve it:
- Your device checks if it has an IP for www.example.com in its cache.
- If not, it contacts the recursive resolver, which goes through the hierarchy to retrieve the IP address.
- The IP address is sent back to your device, which then connects to the web server.
Types of DNS Records in Practice: A domain like mail.example.com might use an A Record to map to 192.0.2.10 and an MX Record to direct emails to the correct mail server.
Note Summary
Common Mistakes
- Confusing DNS with IP addresses: DNS is not the same as an IP address. DNS helps locate the IP address associated with a domain, but they are separate concepts.
- Thinking DNS is a single server: DNS is a distributed, hierarchical system with multiple levels, including root, TLD, and authoritative servers.
- Overlooking DNS caching: DNS caching (locally and within DNS servers) speeds up lookups by temporarily storing results, but it can cause outdated IP addresses if a website's IP changes.
Key Takeaways
- DNS translates domain names into IP addresses, allowing devices to locate each other on the internet.
- The DNS hierarchy involves root servers, TLD servers, and authoritative servers, each playing a specific role in resolving domain names.
- DNS queries follow a step-by-step process, often starting from cache and moving through various DNS servers if necessary.
- Common DNS records include A, AAAA, CNAME, and MX records, each serving different purposes for a domain's functionality.