DNS and How It Gets Abused
Understand DNS resolution and record types, and how attackers use DNS for phishing, tunneling and command-and-control.
Beginner · about 4 hours · difficulty 2/5
Learn first: How the Internet and TCP/IP Work
DNS turns names like example.com into IP addresses. It is also one of the richest data sources in security, because almost every connection starts with a lookup.
How resolution works
Your device asks a recursive resolver (your ISP, 1.1.1.1 or 8.8.8.8). If it has no cached answer, it walks the hierarchy: root servers, then the .com TLD servers, then the domain's authoritative nameserver. Answers are cached for their TTL.
Record types
A/AAAA: IPv4 / IPv6 addressCNAME: alias to another nameMX: mail serversTXT: free text, used for SPF, DKIM and DMARC email security and domain verificationNS: authoritative nameserversPTR: reverse lookup from IP to name
Try dig example.com A, dig example.com MX and nslookup on Windows.
Security angles
- Recon: subdomains and DNS records reveal infrastructure. Certificate transparency logs expose more names.
- Phishing: look-alike domains and newly registered domains are strong signals.
- Tunneling and C2: malware can hide data inside DNS queries; long random subdomains are a tell.
- Hijacking and takeover: dangling CNAMEs pointing to deleted cloud resources can let an attacker claim your subdomain.
- Email security: SPF, DKIM and DMARC records reduce spoofing.
Pitfalls
- Forgetting caching when troubleshooting or investigating; old answers linger until the TTL expires.
Good enough: you can resolve a domain's full record set with dig, explain each record, and spot suspicious-looking queries in a DNS log.
Key concepts
- Recursive vs authoritative servers
- Record types (A, CNAME, MX, TXT, NS)
- TTL and caching
- dig and nslookup
- SPF, DKIM and DMARC
- DNS tunneling and C2
- Subdomain takeover
Mini project
Pick five well-known domains and document their A, MX, NS and TXT records, including whether each has a DMARC policy and what it says.
Check yourself
A workstation makes thousands of DNS queries to long random subdomains of one unfamiliar domain. What might be happening?
Free resources
- Cloudflare: What is DNS? (Cloudflare)
- How DNS Works (comic) (DNSimple)
- DMARC.org overview (DMARC.org)