0Pricing
Cyber Security Academy · Lesson

How DNS Works and Its Risks

The resolution process and attack surface.

How DNS Works and Its Risks is a free Cyber Security Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Cyber Security Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Why DNS Matters for Security

The Domain Name System (DNS) translates human-friendly names like example.com into IP addresses such as 93.184.216.34. Almost every network transaction starts with a DNS lookup, which makes DNS a high-value target.

If an attacker controls or manipulates name resolution, they can silently redirect victims to malicious servers, intercept traffic, or exfiltrate data without touching the application itself. Understanding the resolution path is the first step to defending it.

The Resolution Chain

A typical recursive lookup walks a chain of servers:

  • Stub resolver on the client (the OS).
  • Recursive resolver (your ISP or 8.8.8.8) that does the legwork.
  • Root servers that point to the TLD servers.
  • TLD servers (e.g. .com) that point to authoritative servers.
  • Authoritative servers that hold the real records.

Each hop is a potential interception or spoofing point.

Recursive vs Authoritative

A recursive resolver answers any query by chasing referrals on the client behalf and caching the result. An authoritative server answers only for the zones it owns, with the definitive data.

Security-wise: open recursive resolvers can be abused for amplification attacks, while authoritative servers are targets for zone hijacking and registrar compromise. Keep recursion closed to your own network.

Common Record Types

Records you will meet during analysis:

  • A / AAAA — IPv4 / IPv6 address.
  • CNAME — alias to another name (watch for dangling CNAMEs leading to subdomain takeover).
  • MX — mail servers.
  • NS — delegation to authoritative servers.
  • TXT — free text, used for SPF, DKIM, and often abused for tunneling.

DNS Uses UDP Port 53

Classic DNS runs over UDP port 53, with a fallback to TCP 53 for large responses and zone transfers. UDP is connectionless and stateless, so there is no handshake to prove the responder is who it claims to be.

The only correlation between a query and its answer is a 16-bit transaction ID and the source port. This weak binding is the root cause of spoofing and cache poisoning.

dig +short example.com A
dig example.com MX
dig @8.8.8.8 example.com

Caching and TTL

To reduce load, resolvers cache answers for the duration of the record TTL (time to live). A response with TTL 3600 stays cached for one hour.

Caching is a double-edged sword: it improves performance but means a single poisoned answer can serve many victims until the TTL expires. Attackers often try to push long TTLs to make malicious entries persist.

The Attack Surface

DNS exposes many surfaces:

  • On-path spoofing — forging responses faster than the legitimate server.
  • Cache poisoning — injecting bad records into a resolver cache.
  • Registrar / zone hijack — stealing control of the domain itself.
  • Tunneling — encoding data inside queries to bypass egress controls.
  • DDoS amplification — abusing open resolvers as reflectors.

Lack of Authentication by Default

Plain DNS provides no integrity or authenticity guarantee. A response is trusted if it matches the source IP, destination port, query name, and transaction ID. All of these can be guessed or observed by an on-path attacker.

This design assumption (the network is trustworthy) is why bolt-on protections like DNSSEC, DNS over TLS (DoT), and DNS over HTTPS (DoH) exist.

DNS as a Recon Goldmine

Before attacking, adversaries enumerate DNS to map your estate. Misconfigured zone transfers (AXFR) can dump every record. Subdomain brute-forcing and certificate transparency logs reveal hidden hosts.

Defenders should restrict zone transfers to known secondaries and monitor for bulk query patterns that signal enumeration.

dig AXFR example.com @ns1.example.com
# Should fail / be refused on a hardened server

Encrypted Transport: DoT and DoH

DNS over TLS (port 853) and DNS over HTTPS (port 443) encrypt the query so on-path observers cannot read or tamper with it. This blunts spoofing and protects privacy.

The trade-off for defenders: encrypted DNS can blind your own filtering and monitoring. Many enterprises pin clients to a controlled DoH/DoT resolver rather than letting endpoints choose external ones.

Defender Takeaways

Practical hardening for the resolution path:

  • Run internal recursive resolvers; block direct outbound port 53 to the internet.
  • Disable open recursion on authoritative servers.
  • Restrict and log AXFR zone transfers.
  • Lock the domain at the registrar (registry lock, MFA).
  • Monitor query volume and entropy for tunneling and enumeration.

Quick Check

Test your understanding of why DNS is exposed.

Recap

You learned that DNS resolution walks a chain from stub resolver through root, TLD, and authoritative servers, and that answers are cached by TTL. Because classic DNS over UDP/53 lacks authentication, it is exposed to spoofing, cache poisoning, hijacking, tunneling, and amplification.

Key defenses: closed recursion, restricted zone transfers, registrar locks, encrypted transport (DoT/DoH), and DNSSEC. Next, we dig into spoofing and cache poisoning in detail.

Frequently asked questions

Is the “How DNS Works and Its Risks” lesson free?

Yes — the full text of “How DNS Works and Its Risks” is free to read here on the web, and the Cyber Security Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Cyber Security Academy course, upgrade to CoddyKit PRO.

What will I learn in “How DNS Works and Its Risks”?

The resolution process and attack surface. You practise Cyber Security Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Cyber Security Academy?

No prior experience is required. Cyber Security Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “How DNS Works and Its Risks” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Cyber Security Academy lesson?

Yes. Every Cyber Security Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. How DNS Works and Its Risks
  2. DNS Spoofing and Cache Poisoning
  3. DNS Tunneling and Exfiltration
  4. DNSSEC and DNS Filtering
← Back to Cyber Security Academy