Skip to content
BoKSA

08 – DNS: the Domain Name System

08 – DNS: the Domain Name System

Course: ICT Basic course · Level: introductory Book: Kurose & Ross, 9th ed., chapter 2.4 (DNS – the Internet's directory service)

Learning goals

After this article you can:

  • explain why we need DNS and which services it provides;
  • describe the DNS hierarchy: root, TLD and authoritative servers, and the local resolver;
  • explain the difference between iterative and recursive queries, and the role of caching and TTL;
  • recognise the most important resource records (A, AAAA, CNAME, NS, MX, TXT, PTR, SOA);
  • use dig, nslookup and host to query DNS;
  • explain DNS threats and protections: spoofing/cache poisoning, DNSSEC, DoH/DoT.

1. Why DNS?

  • People like names: www.hva.nl.
  • Computers and routers need IP addresses: 145.18.x.x (IPv4) or 2001:610:... (IPv6).

DNS translates between the two. It is:

  • a distributed, hierarchical database spread over millions of servers;
  • an application-layer protocol (mostly over UDP port 53; TCP 53 for large answers and zone transfers).

It's a core Internet function, but it runs at the edge as an application, not inside routers.

DNS services

Service Example
Name → IP address www.hva.nl → A/AAAA record
Host aliasing www.example.com is an alias (CNAME) for example.cdn-provider.net
Mail server aliasing MX record: mail for @hva.nl goes to Microsoft 365
Load distribution one name returns several IP addresses, or different answers depending on where you are (CDNs)
Other information TXT (SPF/DKIM/DMARC, domain verification), CAA, HTTPS/SVCB records

Why not one central DNS server?

It would be a single point of failure, have to handle an enormous traffic volume, be far away for most users, and be impossible to maintain. So DNS is distributed.


2. The DNS hierarchy

1
2
3
4
5
6
7
                          . (root)
          ┌────────────────┼──────────────────┬───────────┐
        com               org                 nl          edu     ← TLD servers
     ┌───┴────┐            │              ┌───┴────┐
  google   amazon         pbs            hva      uva            ← authoritative servers
                                          │
                                         www
Server type Role Examples
Root servers know the TLD servers 13 root server identities (a.root-servers.net … m.root-servers.net), operated by 12 organisations, with more than 2,000 instances worldwide using anycast (one IP address, many locations). One of them, k-root, is run by RIPE NCC in Amsterdam
TLD servers know the authoritative servers for every domain under their TLD generic: .com, .org, .net, .app; country-code: .nl (run by SIDN in Arnhem), .de, .uk; Verisign runs .com
Authoritative servers give the official answer for a domain run by the organisation itself or by a DNS provider (Cloudflare, AWS Route 53, TransIP...)
Local DNS server / recursive resolver not part of the hierarchy; does the lookup work for clients and caches answers your ISP's resolver, the company resolver, or public resolvers: 1.1.1.1 (Cloudflare), 8.8.8.8 (Google), 9.9.9.9 (Quad9)

Updated: older slides show a map of 13 root "servers" with a few locations each. Today there are more than 2,000 root instances (see root-servers.org), so there's almost always one close to you.


3. Resolving a name

Your laptop asks its local resolver. The resolver then walks the hierarchy:

1
2
3
4
5
6
7
  laptop ──(1) www.hva.nl?──► local resolver ──(2)──► root server
                                    │       ◄─(3)── "ask the .nl servers: ns1.dns.nl ..."
                                    │──(4)──► .nl TLD server
                                    │       ◄─(5)── "ask hva.nl's servers: ns1.hva.nl ..."
                                    │──(6)──► authoritative server of hva.nl
                                    │       ◄─(7)── "www.hva.nl = 145.18.x.x"
  laptop ◄──(8) 145.18.x.x ──────────┘   (and stores the answer in its cache)
  • Recursive query (laptop → resolver): "please give me the final answer".
  • Iterative queries (resolver → root/TLD/authoritative): "I don't know, but ask that server".

Caching and TTL

Every answer has a TTL (Time To Live) in seconds. Resolvers (and your OS/browser) cache answers until the TTL expires. - Fast: most lookups are answered from cache in a few ms. - The root servers are rarely asked, because TLD information is cached for a long time (TTL of 2 days). - Downside: after you change a record, old answers can remain for up to the TTL ("DNS propagation").


4. Resource records

Format: name TTL class type value

Type Meaning Example
A IPv4 address of a host www.example.nl. 3600 IN A 93.184.215.14
AAAA IPv6 address of a host www.example.nl. 3600 IN AAAA 2606:2800:21f:cb07:6820:80da:af6b:8b2c
CNAME alias → canonical name www.example.nl. IN CNAME example.nl.
NS authoritative name server for a domain example.nl. IN NS ns1.provider.nl.
MX mail server for a domain (with priority) example.nl. IN MX 10 mail.example.nl.
TXT free text: SPF, DKIM, DMARC, verification codes example.nl. IN TXT "v=spf1 -all"
PTR reverse lookup: IP → name 14.215.184.93.in-addr.arpa. IN PTR www.example.nl.
SOA start of authority: zone information (serial, timers)
CAA which certificate authorities may issue certificates for the domain example.nl. IN CAA 0 issue "letsencrypt.org"
HTTPS / SVCB service information: supported protocols (e.g. HTTP/3), alternative endpoints example.nl. IN HTTPS 1 . alpn="h3,h2"

5. Try it yourself

Tools: on Debian: sudo apt install dnsutils (for dig/nslookup). Windows has nslookup and the PowerShell command Resolve-DnsName.

1
2
3
4
5
6
7
8
9
dig www.hva.nl                  # A record + full answer section
dig AAAA www.google.com +short  # IPv6 address
dig MX hva.nl +short            # mail servers
dig NS nl +short                # name servers of the .nl TLD
dig @1.1.1.1 www.hva.nl         # ask a specific resolver
dig +trace www.hva.nl           # follow the whole path: root → .nl → hva.nl
dig -x 1.1.1.1 +short           # reverse lookup (PTR)
dig www.hva.nl +dnssec          # show DNSSEC signatures (RRSIG), if any
nslookup www.hva.nl 9.9.9.9     # nslookup with a specific server

Questions: 1. What is the TTL of www.hva.nl? Run dig twice on the same resolver. Does the TTL go down? 2. With dig +trace: which root server and which .nl server answered? 3. Does hva.nl have a CAA record? An HTTPS record? 4. Capture a DNS lookup in Wireshark (filter: dns). Which transport protocol and port are used? Find the query ID. 5. Visual explanation: read the comic at https://howdns.works/.

Check your understanding

  1. Name four services that DNS provides.
  2. Why is DNS not centralised?
  3. What is the difference between a recursive and an iterative query?
  4. What does the TTL of a record do?
  5. Which record types do you need for a website with IPv4 and IPv6, and for mail?

References

Book

  • Kurose & Ross, 9th ed., chapter 2.4

Videos

Articles and tools


Cyber Security

Why is this important for cyber security?

DNS is the "phone book" of the Internet. If DNS lies, you go to the wrong place, even when you type the right address.

Threat What happens
DNS spoofing / cache poisoning an attacker sends fake answers to a resolver; the resolver caches them and sends all users to the attacker's server (the Kaminsky attack, 2008, showed how easy this was)
DNS hijacking changing DNS settings on a router or device (malware), or taking over a domain's account at the registrar, so all traffic is redirected
Eavesdropping classic DNS is unencrypted: your ISP, the Wi-Fi owner or an attacker can see every site you visit
DNS amplification (DDoS) attackers send small queries with a spoofed source address; large answers flood the victim
DDoS on DNS providers the 2016 attack on Dyn (Mirai botnet) made Twitter, Netflix and others unreachable
Typosquatting / look-alike domains hva-nl.com, rnicrosoft.com for phishing
Subdomain takeover a CNAME points to a cloud resource that no longer exists; an attacker claims it
DNS tunnelling malware hides data in DNS queries to get past firewalls

What can you do to make it safe?

  • DNSSEC – the owner digitally signs DNS records; validating resolvers check the signatures, so forged answers are rejected. The signatures form a chain of trust from the root down. The .nl domain is one of the most DNSSEC-signed domains in the world (SIDN gave registrars an incentive for it). DNSSEC provides integrity and authenticity, not confidentiality. (Older slides said the reply has a "certificate signed by a Certificate Authority". That's not accurate: DNSSEC uses its own key hierarchy in DNS (DNSKEY/RRSIG/DS records), not CA certificates.)
  • Encrypted DNS – protects confidentiality:
  • DoT – DNS over TLS (TCP 853)
  • DoH – DNS over HTTPS (TCP/UDP 443): built into Firefox, Chrome, Edge, Windows 11, Android, iOS
  • DoQ – DNS over QUIC
  • Use a trusted, validating resolver, e.g. Quad9 (9.9.9.9), which also blocks known malicious domains. Many companies use protective DNS for this.
  • Domain hygiene: turn on registrar lock and MFA at your registrar, remove old (dangling) DNS records, and use CAA records.
  • Configure resolvers safely: no open resolvers on the Internet; limit recursion to your own network.
  • Monitor DNS logs: many malware infections and data leaks are visible in DNS traffic.

Extra references