๐งฑ The OSI model: where DNS lives, and what's underneath
Before DNS makes sense, you need a picture of the layers it sits on. When DNS misbehaves, the cause is almost always in a layer below it. This page is the map.
The 7 layers, in 60 seconds#
| # | Layer | What it moves | Example | What it answers |
|---|---|---|---|---|
| 7 | Application | Data | DNS, HTTP, SSH, SMTP | "What does the program want?" |
| 6 | Presentation | Encoded data | TLS, character encodings | "What does the data mean once decoded?" |
| 5 | Session | Conversations | Less relevant on TCP/IP networks | "Are we still talking?" |
| 4 | Transport | Segments | TCP, UDP, QUIC | "Did it arrive, and in order?" |
| 3 | Network | Packets | IPv4, IPv6, ICMP | "How do I route this across networks?" |
| 2 | Data link | Frames | Ethernet, ARP, 802.1Q VLAN tags | "How do I hand this to the next hop on this wire?" |
| 1 | Physical | Bits | Copper, fiber, radio | "Is the cable plugged in?" |
The OSI model is a teaching abstraction. The real TCP/IP stack collapses 5/6/7 into one "Application" layer in practice (RFC 1122 defines just four layers: application, transport, internet, link). But the seven boxes are still the language people use to point at where something is broken, and that's why you learn it.
Where DNS lives: and what it depends on#
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ L7 Application โ DNS โ "dig example.com"
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ L6 Presentation โ TLS (for DoT / DoH) โ only when encrypted
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ L4 Transport โ UDP/53 (or TCP/53) โ most queries are UDP
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ L3 Network โ IP (v4 or v6) routing โ resolver must be reachable
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ L2 Data link โ Ethernet + VLAN tag โ right port, right VLAN
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ L1 Physical โ cable / Wi-Fi โ the cable is in
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโA DNS query is a tiny application-layer message that has to ride every layer below it to reach a resolver. Any of those layers can swallow it silently:
- L1 down: no link, no DNS.
- L2 wrong VLAN: frame is dropped at the switch port. Resolver looks unreachable. See the L2 section below.
- L3 no route:
tracerouteto the resolver dies before it arrives. - L4 firewall blocks port 53: every query times out. The subtler variant: UDP/53 is open but TCP/53 is blocked, so everything works until a response is too big for UDP (truncation forces a retry over TCP) or a zone transfer is needed. RFC 7766 requires DNS implementations to support both transports; firewalls that allow only UDP/53 are misconfigured.
- L6 TLS mismatch: DoT/DoH negotiation fails; plain Do53 on port 53 still works, which confuses the picture.
- L7 server returns
SERVFAIL: the only one that's actually DNS. See dnssec if the failure is DNSSEC-related.
This is why old hands debug bottom-up. Cable โ VLAN โ IP โ port โ DNS. Each step takes seconds. Starting at L7 and working down is how you lose an afternoon.
The "is it DNS?" loop, layered#
The three-stage incident (it's not DNS ยท there's no way it's DNS ยท it was DNS) is funny precisely because everyone reaches for L7 first. The wiki's whole premise is: once you can prove which layer broke, you stop guessing.
"DNS is broken"
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Is L1 up? โ ip link, cable, Wi-Fi โ
โ Is L2 right? โ correct VLAN, ARP works โ
โ Is L3 reachable? โ ping the resolver โ
โ Is L4 open? โ nc -z resolver 53 โ
โ Does DNS work? โ dig @resolver isitdns.netโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
one of those said "no", that's the layerHere is what each step looks like as an actual command, using 1.1.1.1 as a stand-in for your resolver:
L3: can you reach the resolver at all?
ping -c 3 1.1.1.1L4: is port 53 open? (TCP probe)
nc -z 1.1.1.1 53For UDP/53 specifically, nc -u reports success even on a closed port on most systems because UDP is connectionless. Use a real DNS round-trip instead:
dig @1.1.1.1 example.isitdns.net +tries=1 +time=2If this returns a response, UDP/53 is open and the resolver is answering. The expected answer is a single A record, 192.0.2.1: a documentation address (RFC 5737) that resolves on purpose but routes nowhere, so the lookup is safe to run anywhere. See the address section below for why this wiki's example records work that way. If the query times out, port 53 UDP is blocked somewhere between you and the resolver.
nslookupcannot probe individual layers. Usencfor TCP L4,digfor UDP L4,pingfor L3.
L7: does DNS respond correctly?
dig @1.1.1.1 isitdns.net Anslookup -type=A isitdns.net 1.1.1.1If ping and nc both succeed but dig fails, the problem is at L7. If ping fails, look at L3 routing or L2 VLAN config. If dig returns SERVFAIL, retry the same query with +cd (checking disabled): if the +cd retry succeeds, the network path is fine and you are looking at a broken dnssec chain on a validating resolver, not a network problem. (A SERVFAIL never carries the ad flag, so the flag's absence tells you nothing there.)
What lives at each layer (typical DNS-serving environment)#
A concrete map you can point at when something breaks:
| Layer | What you'll usually find |
|---|---|
| L7 | The DNS server itself: authoritative, recursive, or both. Could be a home router's built-in resolver, an open-source DNS server, or a commercial DNS appliance. See query-types for the resolver role breakdown. |
| L6 | TLS terminations for DoT (:853) and DoH (:443). DoQ folds its TLS 1.3 into the QUIC layer itself, so no separate L6 TLS step is visible to a troubleshooter. |
| L4 | UDP/53 + TCP/53 for classic DNS (both are mandatory per RFC 7766), TCP/853 for DoT (RFC 7858), UDP/853 for DoQ (RFC 9250), TCP/443 for DoH (RFC 8484), or UDP/443 when DoH rides HTTP/3 |
| L3 | IPv4 + IPv6 routing to the resolver, public or private addressing. See the address section below for the ranges you'll encounter. |
| L2 | Ethernet with 802.1Q VLAN tagging if the network is segmented. See the L2 section below. |
| L1 | Whatever copper, fiber, or radio link the resolver actually sits on |
Layer 2 in practice: ARP and VLANs#
DNS does not run at L2, but every query crosses your local segment twice, query out and answer back, and a misconfigured switch port drops the frame with no error anywhere. The application sees a timeout and blames DNS. Two mechanisms cover most of it.
ARP is the step before any query leaves. Your host knows the resolver's IP but a frame needs a destination MAC, so it broadcasts "who has this IP?" (RFC 826) and caches the answer. If the resolver sits on a different subnet, the host ARPs for its default gateway instead, and it is the gateway's MAC that lands in the cache. IPv6 does the same job with NDP (RFC 4861). Check the cache:
ip neighEntries in REACHABLE or STALE are healthy (STALE only means "not confirmed recently"). The resolver or gateway stuck in INCOMPLETE or FAILED means the query never made it onto the wire: dig retries with ;; communications error to <resolver>#53: timed out and ends with ;; no servers could be reached. macOS ships arp -a instead of ip neigh.
VLANs decide which wire you are on. An 802.1Q tag (IEEE Std 802.1Q) is 4 bytes in the Ethernet frame that assign it to a broadcast domain; a switch only forwards the frame to ports in the same VLAN. A port on the wrong VLAN, a trunk with a wrong allowed list, or a native-VLAN mismatch between two switches all fail the same way: the frame is silently gone. What that looks like from the DNS side:
| Symptom | Likely L2 cause |
|---|---|
dig times out and ip neigh shows the resolver INCOMPLETE or FAILED | ARP never got an answer: wrong VLAN at the client's port |
| One host resolves, another on the same subnet cannot | Two ports on two different VLANs, same L3 subnet on paper |
| Internal names resolve, every external query fails after a timeout | Resolver forwards upstream to a gateway address on a different VLAN, and the gateway only answers on the interface facing each segment |
arp -d "fixes" it for a minute | Stale ARP entry: the IP moved between MACs (HA failover, VM migration) and the cache did not refresh |
To prove whether frames are tagged, capture on the trunk parent interface; tcpdump decodes the 802.1Q header and prints the VLAN ID on every match:
sudo tcpdump -ni eth0 -e -c 2 'vlan and port 53'ethertype 802.1Q (0x8100) plus vlan 101 in the output means the query crossed the trunk tagged for VLAN 101. A wrong ID, or no tag where you expected one, points at the switch port or sub-interface configuration, not the resolver. On an access port this filter matches nothing, because the switch strips the tag before the frame reaches you. More capture filters live on wireshark-dns-filters.
The addresses you'll meet#
Three kinds of IP address show up in DNS work, and knowing which is which keeps you from leaking your own network or breaking an example:
| Category | Ranges | Property |
|---|---|---|
| Public | ISP-assigned or RIR-allocated | Routable and identifying. Do not publish yours in docs. |
| Private | 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 (RFC 1918); ULA fc00::/7, of which fd00::/8 is the locally assigned half everyone actually uses (RFC 4193) | Routes only inside your network. Everyone uses the same numbers, so they identify nothing. |
| Documentation | 192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24 (RFC 5737); 2001:db8::/32 (RFC 3849); reserved names like example.com and .test (RFC 2606) | Reserved for examples. Guaranteed never to route. |
This wiki's live examples mix the last row with a real zone: example.isitdns.net publishes an A record of 192.0.2.1 and an AAAA record of 2001:db8::1. Both resolve, so every example is runnable; neither routes, so no packet lands on anyone's real host:
dig @1.1.1.1 example.isitdns.net A +short192.0.2.1Two DNS consequences worth keeping in your head:
- Reverse lookups for private space never resolve in the public tree. Resolvers serve the RFC 1918 reverse zones out of their own local data (RFC 6303), which means
NXDOMAINfor any address inside the block, and queries that escape anyway land on the AS112 blackhole servers (RFC 7534), which answer the same way below the zone name. Reverse DNS for your192.168.0.0/24means standing up your own zone; the mechanics are on reverse-dns. - Split-horizon DNS serves RFC 1918 answers internally and public ones externally, same name, two record sets, picked by the client's source address.
When writing anything public, substitute a documentation address. The ranges exist exactly so you never have to make that call under pressure.
Rule of thumb#
Troubleshoot the stack in order. Each layer tells you where to go next: link, then address, then route, then port, then resolver, then zone. Start at the bottom and stop at the first layer that fails.
See also#
- anatomy-of-a-query: once the layers are up, what actually happens inside the DNS protocol
- query-types: recursive, iterative, and forwarding query types
- dot-doh: DNS over TLS and DNS over HTTPS, the L6 story
- dnssec: DNSSEC validation, the L7 security layer
- reverse-dns: where private address space meets the DNS tree
- wireshark-dns-filters: capture filters for every layer, L2 tags included
- nslookup-and-dig: the two CLI tools for testing every layer from L7 down