DNS (Domain Name System)
Machines communicate with IP addresses. Humans prefer readable domain names. Instead of typing 142.250.64.78, we type www.google.com.
DNS is a global distributed directory that maps:
Domain Name → IP Address
[www.google.com](http://www.google.com) → 142.250.64.78
Structure of the DNS System
DNS is a hierarchical, distributed, and redundant system. It functions like an inverted tree.
Example: www.example.com
.com→ top-level domain (TLD)example.com→ second-level domainwww.example.com→ subdomain (or FQDN: Fully Qualified Domain Name)
How DNS Resolution Works
When a client wants to contact www.example.com:
- It checks its local DNS cache. If the IP address is found, it uses it and the process stops here.
- Otherwise, it queries its DNS resolver (often configured by DHCP).
- The resolver asks the root DNS servers (
.). - They refer to the TLD server for
.com. - The TLD refers to the authoritative DNS server for
example.com. - This one responds with the IP address of
www.example.com.
The client can now contact the returned IP address. As illustrated in the diagram below, it is the DNS resolver that does the lookup work. The client does not need to know the hierarchy of DNS servers.
DNS Cache
To improve performance:
- Each DNS response is cached, with a TTL (Time To Live).
- The client or resolver can reuse the response for a certain time.
- This avoids redoing the entire chain each time.
DNS Servers: Roles
| Type of DNS Server | Main Role |
|---|---|
| Resolver | Makes the query for the client |
| Root (root servers) | Starting point (13 global root servers) |
| TLD servers (.com, .org) | Manage top-level domains |
| Authoritative | Knows the records of a given domain |
Types of DNS Records
| Type | Description | Example |
|---|---|---|
| A | IPv4 Address | example.com → 93.184.216.34 |
| AAAA | IPv6 Address | example.com → 2606:2800:... |
| MX | Mail Server | gmail.com → mail.gmail.com |
| CNAME | Alias of another name | www → example.com |
| NS | Authoritative DNS servers | example.com → ns1.example.net |
| TXT | Miscellaneous information (e.g., SPF) | Used for authentication |
DNS Testing Tools (Windows)
nslookup
Manually queries a DNS server and displays the associated IP address.
nslookup www.google.com
To change DNS server (google dns: server 8.8.8.8).
nslookup github.com 8.8.8.8
ping and tracert
ping www.google.com→ Resolves the name to IPtracert www.google.com→ Shows the network path
Popular Public DNS Servers
| Provider | DNS Address | Remarks |
|---|---|---|
8.8.8.8, 8.8.4.4 | Fast, reliable | |
| Cloudflare | 1.1.1.1 | Privacy-focused |
| OpenDNS | 208.67.222.222 | Parental controls |
Common DNS Issues
| Symptom | Possible Cause |
|---|---|
| Web page inaccessible | Misconfigured or unreachable DNS |
| Slow DNS resolution | Distant or overloaded server |
| Domain name resolved to wrong IP | Cache issue or DNS attack (spoofing) |
Security and DNS
-
DNS is historically unencrypted.
-
New methods like DNS over HTTPS (DoH) or DNSSEC allow:
- Encryption of queries.
- Signing of DNS responses to prevent tampering.
Summary
| Element | Role |
|---|---|
| DNS | Translates names into IP addresses |
| Recursive resolution | Client → Resolver → Root → TLD → Authoritative Server |
| Cache | Improves performance (TTL) |
nslookup | Manual DNS resolution testing tool |