Edexcel International Advanced Level Computer Science, point 12.1.4
Definition
The domain name system (DNS) is a distributed system that translates human-readable domain names (such as www.example.com) into IP addresses (such as 93.184.216.34). It is often called the phone book of the Internet.
Function and why needed
- People remember names, but computers and routers use IP addresses (3.1.3).
- Server IP addresses can change (a website moves hosts), but its name stays the same. DNS hides this.
- One name can map to several addresses (for load balancing).
Characteristics
Domain name structure
A domain name is read from right to left, most general to most specific:
The DNS hierarchy
DNS is a hierarchy of servers, so no single computer holds every record:
| Server | Role |
|---|---|
| DNS resolver (recursive resolver) | Does the searching on behalf of your device, usually run by your ISP (or a public one). It holds a cache |
| Root name servers | Know where the servers for each TLD are |
| TLD name servers | Know the authoritative servers for each domain under that TLD (for example .com) |
| Authoritative name server | Holds the actual records for a domain (the final answer) |
Common record types
| Record | Maps |
|---|---|
| A | Name to IPv4 address |
| AAAA | Name to IPv6 address |
| CNAME | One name to another name (an alias) |
| MX | Domain to its mail servers |
| NS | Domain to its name servers |
Operation: resolving a name
Example: a user types www.example.com.
- The browser checks its own cache, then the operating system's cache (and the
hostsfile). If found, it uses it and stops. - If not, the device asks the DNS resolver (the configured DNS server).
- The resolver checks its cache. If found, it answers at once.
- If not, it asks a root server, which points it to the
.comTLD server. - The resolver asks the TLD server, which points it to the authoritative server for
example.com. - The resolver asks the authoritative server, which returns the IP address (the A record).
- The resolver caches the answer (for the time to live (TTL) set on the record) and returns it to the device.
- The browser connects to that IP address, using TCP/IP (12.1.2).
Caching
DNS answers are stored (cached) at the browser, the operating system, and the resolver, for a time set by the record's TTL. This:
- Speeds up repeat lookups (no need to ask the whole hierarchy).
- Reduces load on the DNS servers.
- But can serve out-of-date addresses until the TTL expires (changes take time to spread).
Benefits
- Easy to use: people use names, not numbers.
- Flexible: a site can change its IP address without users noticing.
- Scalable and resilient: distributed across many servers, with no single point of failure, and caching reduces load.
- Supports load balancing and email routing (MX).
Drawbacks and risks
- A lookup adds delay to the first visit (reduced by caching).
- If DNS fails, websites seem unreachable even when they are working.
- DNS spoofing (cache poisoning): false records inserted so that a name points to a fraudulent server.
- DNS lookups can be monitored, so privacy is a concern (encrypted DNS such as DNS over HTTPS helps).
- DDoS attacks on DNS servers can take many sites offline.
- Stale cache entries can send users to old addresses.
Worked example
Task: explain what happens the first time and the second time a user visits www.bbc.co.uk.
First visit:
- The browser and OS have no cached address.
- The device asks the resolver, which also has no record.
- The resolver works down the hierarchy: root, then the
.ukTLD server, then theco.ukandbbc.co.ukauthoritative server, which returns the IP address. - The resolver caches it and passes it back, and the browser caches it too.
- The browser connects to the IP address.
Second visit (shortly after): the browser cache has the address already, so no DNS request is sent at all, and the page request starts at once. The lookup is much faster.
If the site changes its address, users may keep the old one until the cached entry's TTL runs out.
Exam tip: state that DNS translates domain names to IP addresses, and describe the order: cache, resolver, root, TLD, authoritative, answer returned and cached. You may be asked to complete a diagram of how DNS works, so keep the servers in order. Mention caching as a benefit, and spoofing as a risk.
Check yourself
What does DNS do?
It translates human-readable domain names into IP addresses.
State the servers a resolver may contact when it has no cached answer
A root name server, then a top-level domain (TLD) name server, then the authoritative name server for the domain.
Why is DNS caching used?
It speeds up repeat lookups and reduces load on the DNS servers.
Give one security risk of DNS
DNS spoofing (cache poisoning), where false records send users to a fraudulent site; or denial-of-service attacks on DNS servers.
What is the difference between an A record and an AAAA record?
An A record maps a name to an IPv4 address; an AAAA record maps it to an IPv6 address.