Skip to main content

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 domain
  • www.example.com → subdomain (or FQDN: Fully Qualified Domain Name)

How DNS Resolution Works​

When a client wants to contact www.example.com:

  1. It checks its local DNS cache. If the IP address is found, it uses it and the process stops here.
  2. Otherwise, it queries its DNS resolver (often configured by DHCP).
  3. The resolver asks the root DNS servers (.).
  4. They refer to the TLD server for .com.
  5. The TLD refers to the authoritative DNS server for example.com.
  6. 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 ServerMain Role
ResolverMakes the query for the client
Root (root servers)Starting point (13 global root servers)
TLD servers (.com, .org)Manage top-level domains
AuthoritativeKnows the records of a given domain

Types of DNS Records​

TypeDescriptionExample
AIPv4 Addressexample.com → 93.184.216.34
AAAAIPv6 Addressexample.com → 2606:2800:...
MXMail Servergmail.com → mail.gmail.com
CNAMEAlias of another namewww → example.com
NSAuthoritative DNS serversexample.com → ns1.example.net
TXTMiscellaneous 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 IP
  • tracert www.google.com → Shows the network path
ProviderDNS AddressRemarks
Google8.8.8.8, 8.8.4.4Fast, reliable
Cloudflare1.1.1.1Privacy-focused
OpenDNS208.67.222.222Parental controls

Common DNS Issues​

SymptomPossible Cause
Web page inaccessibleMisconfigured or unreachable DNS
Slow DNS resolutionDistant or overloaded server
Domain name resolved to wrong IPCache 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​

ElementRole
DNSTranslates names into IP addresses
Recursive resolutionClient → Resolver → Root → TLD → Authoritative Server
CacheImproves performance (TTL)
nslookupManual DNS resolution testing tool