DNS
The Domain Name System turns names into addresses and much more (mail servers, service records, verification). Almost every connection starts with a DNS lookup, which makes it a goldmine for detection and a favourite channel for attackers.
- OSI layer
- 7 Application
- Carried in
- UDP (TCP for large answers and zone transfers)
- Ports
- 53/udp, 53/tcp, 853/tcp (DoT), 443/tcp (DoH), 5353/udp (mDNS)
- Wireshark filter
dns- Encrypted
- no
Packet structure
Select a field to see what it does.
Over TCP the message is prefixed with a 2-byte length. Classic UDP answers are limited to 512 bytes; EDNS0 (an OPT record in the additional section) allows bigger ones, typically 1232 bytes today.
How it works
sequenceDiagram
participant C as Client (stub)
participant R as Recursive resolver
participant Root as Root server
participant TLD as .com server
participant A as example.com server
C->>R: A www.example.com? (RD=1)
R->>Root: www.example.com?
Root-->>R: referral to .com NS
R->>TLD: www.example.com?
TLD-->>R: referral to example.com NS
R->>A: www.example.com?
A-->>R: A 93.184.215.14 (AA=1, TTL 3600)
R-->>C: A 93.184.215.14 (RA=1)
The resolver caches each answer for its TTL, so most lookups are answered from cache. Negative answers (NXDOMAIN) are cached too.
Common record types: A, AAAA, CNAME, MX, NS, TXT, PTR, SOA, SRV (Active Directory uses _ldap._tcp.dc._msdcs.<domain>), CAA, HTTPS/SVCB. Click the Question field above for the type numbers.
In Wireshark
| Filter | Shows |
|---|---|
dns | All DNS (UDP and TCP 53) |
dns.flags.response == 0 | Queries |
dns.qry.name contains "example" | Lookups for a name |
dns.flags.rcode == 3 | NXDOMAIN (typos, DGA malware, blocked domains) |
dns.flags.rcode == 2 | SERVFAIL |
dns.qry.type == 16 | TXT queries (verification, tunnels) |
dns.qry.type == 252 | Zone transfer attempts (AXFR) |
dns.qry.type == 255 | ANY queries (amplification) |
dns.flags.truncated == 1 | Truncated answers, retried over TCP |
len(dns.qry.name) > 50 | Very long names (tunnelling, encoded data) |
dns && !(ip.dst == 10.0.0.53 or ip.src == 10.0.0.53) | DNS that bypasses your resolver |
dns.resp.ttl < 60 | Very short TTLs (fast flux, load balancing) |
Statistics › DNS gives a quick overview of query types and response codes.
What normal looks like: clients ask the internal resolver only; query and answer pairs with matching IDs; mostly A, AAAA, HTTPS, PTR and SRV; few NXDOMAINs.
Security notes
- DNS tunnelling and exfiltration: data encoded in subdomains and TXT answers (
iodine,dnscat2, C2 frameworks). Signs: long random-looking labels, many unique subdomains of one domain, lots of TXT/NULL queries, high volume to one zone. - DGA malware: generated domain names cause bursts of NXDOMAINs.
- Cache poisoning: forged answers that win the race against the real one (Kaminsky attack). Randomised source ports and IDs make it hard; DNSSEC prevents it.
- Spoofing on the LAN: answering faster than the resolver from a man-in-the-middle position (
bettercap, rogue DHCP/RA pointing to a fake DNS). - LLMNR / NBT-NS / mDNS poisoning: Windows falls back to these when DNS fails;
Responderanswers and captures NTLM hashes. Disable LLMNR and NBT-NS. - Amplification: open resolvers and ANY/DNSSEC answers turn small spoofed queries into large floods.
- Zone transfers (AXFR): allowed to anyone, they leak all hostnames. Restrict to secondary servers.
- Subdomain takeover: a CNAME pointing to a cloud resource that no longer exists can be claimed by someone else.
- Privacy and visibility: plain DNS shows every name a client visits; DoH/DoT hide it from the network, and from your monitoring if clients bypass the internal resolver.
Versions and related
- DNSSEC signs records (RRSIG, DNSKEY, DS) for integrity, not confidentiality.
- DoT (853/tcp), DoH (HTTPS), DoQ (QUIC): encrypted transports for the same messages.
- mDNS (5353/udp) and LLMNR (5355/udp) resolve names on the local link without a server.
- Usually carried by UDP; DHCP tells clients which resolver to use.