Skip to content
Tech Interview Prep
Technical interview guide

DNS & DHCP

How devices get an IP address automatically, and how domain names get resolved into one.

Minutes to read
4
Practice MCQs
25
Interview Q&A
25
Edition
v5
Editorial status
Reviewed

Scope: Current IETF DNS, negative caching, DNSSEC, DNS over TCP/TLS/HTTPS, DHCPv4/options/relay, DHCPv6, SLAAC, and mDNS references reviewed 2026-09-04.

Interview Q&A

Treat each question like a live interview question: answer out loud first (structure, assumptions, tradeoffs), then open the model answer to spot gaps and rehearse a tighter follow-up.

Curated: · Written: · Reviewed:

25 questions

Q&A-1

Trace a DNS lookup from application to authority.

Answer

The 90-second answer

A DNS lookup is a walk down a delegation tree, with a cache at every hop. I'd trace it as application → stub resolver → recursive resolver → root → TLD → authoritative, and name what each hop caches and what it can return instead of an answer.

Concretely, an app on Linux calling getaddrinfo("api.example.com", ...):

  1. glibc consults /etc/nsswitch.conf (hosts: files dns), misses /etc/hosts, then reads /etc/resolv.conf. With search corp.example.com and the default ndots:1, a name containing at least one dot is tried as absolute first; a bare api would get api.corp.example.com appended before that.
  2. The stub sends one UDP query to the configured nameserver, say 127.0.0.53 (systemd-resolved), port 53, RD=1, random 16-bit ID, EDNS0 OPT advertising a 1232-byte UDP payload (the DNS Flag Day 2020 figure).
  3. If that resolver has the name cached, it answers immediately and the trace stops there. On a miss it recurses from the root hints: 13 root server addresses, a.root-servers.net = 198.41.0.4.

Then the referral chain, which is the part interviewers actually want:

#Query toAnswer sectionAuthority / additionalFlags
1198.41.0.4 (root)emptycom. NS a.gtld-servers.net + glue AAA=0, referral
2192.5.6.30 (a.gtld-servers.net)emptyexample.com. NS ns1.example.com + glueAA=0, referral
3ns1.example.com (203.0.113.53)api.example.com. A 203.0.113.10—AA=1, TTL 300

(Addresses in 203.0.113.0/24 are documentation range, used here as the example zone.)

The root and TLD servers never answer for api.example.com; they only point at the next zone down, and the glue records exist so the resolver doesn't have to resolve the nameserver's own name first. Only the authoritative server sets AA=1. The resolver caches each record for its TTL, 300 s here, so a repeat lookup inside that window is one hop, not four. Negative answers are cached too, for the SOA MINIMUM (RFC 2308), which is why a typo can look "sticky" for minutes after you fix it.

What decides the path

  • UDP vs TCP: UDP by default; if the response exceeds the advertised buffer the server sets TC=1 and the stub retries over TCP:53. DNSSEC-signed zones and large RRsets hit this often.
  • Plain vs encrypted: DoT (853) and DoH (443) hide the query from the local network but remove the middlebox visibility and shared caching you get from a resolver on 53.
  • TTL: 300 s gives fast failover but roughly 5–10× the query volume of 3600 s.

Failure modes to name

  • NXDOMAIN means the name doesn't exist (authoritative, negatively cached). SERVFAIL means the resolver failed: DNSSEC bogus, timeout, or all upstreams down. Different bugs, different fixes.
  • Truncation: TC=1 with no TCP retry shows up as intermittent failures on large answers.
  • Stale TTL after a failover: the old A record keeps being served until it expires.
  • Split-horizon: internal and external resolvers return different answers for the same name; check which resolver the client actually used before debugging the zone.

Curated: · Written: · Reviewed:

Difficulty: Medium
Q&A-6

Design an alias for a service name safely.

Answer

What I'd say first

Clarify four things before picking a mechanism: is the name the zone apex or a subdomain; what does it point at (another name in my zone, an ELB/CloudFront endpoint, a third party); does anything else live at that owner (MX, TXT, NS); and who owns the target's lifecycle. Then: subdomain → CNAME. Apex → a provider alias record, because a CNAME at the apex is illegal.

Why CNAME at the apex is illegal

RFC 1034 §3.6.2: a CNAME owner name must have no other data. The apex must carry SOA and NS. So example.com CNAME lb.example.net is a contradiction: resolvers either SERVFAIL or drop the SOA/NS. That is the record model, not a provider quirk. Route 53 ALIAS, Cloudflare CNAME flattening and Azure alias records exist to give the same "follow this name" behaviour at the apex by returning A/AAAA at answer time.

optionowner can be apexcoexists with MX/TXTcostwhen it loses
CNAMEnonoone extra lookup per hopapex, or any other data at the owner
Route 53 ALIASyesyesfree for AWS targetsnon-AWS targets, non-Route53 zones
Cloudflare CNAME flatteningyesyesfreeonly inside Cloudflare
A/AAAA to a static IPyesyesnonetarget IP changes; you own failover

Trace

$ dig +noall +answer api.example.com
api.example.com.     300 IN CNAME lb.prod.example.net.
lb.prod.example.net.  60 IN A     203.0.113.10

Two TTLs, two cache entries. The CNAME is cached 300s, the A 60s. If you repoint the CNAME, resolvers that already cached it keep the old target for up to 300s. Lower the CNAME TTL to 60 before a migration, wait one old TTL, then cut.

Failure modes

  • Loop: a CNAME b, b CNAME a. Resolvers detect the cycle and return SERVFAIL; dig +trace shows it immediately. Chains also cost one RTT per hop, and resolvers cap the chain length (BIND's default is 16), so keep it to one hop.
  • Dangling target: target deleted, alias still resolves to NXDOMAIN. Subdomain takeover if the target is a third-party host. Monitor with an external resolver and alert on NXDOMAIN.
  • Cert mismatch: the cert must cover the user-facing name, not the target. api.example.com aliased to lb.prod.example.net needs api.example.com in the SAN; SNI sends the user-facing name.
  • DNSSEC: the CNAME RRset is signed in its own zone; validation of the target is a separate chain, so a signed alias to an unsigned target still validates the alias leg.
  • Failover: Route 53 ALIAS plus a health check gives failover at the alias; a plain CNAME gives none. The resolver just caches whatever the target said.

Curated: · Written: · Reviewed:

Difficulty: Medium
Q&A-4

Plan a low-risk DNS endpoint migration.

Answer

What I'd say in the first two minutes

Before touching anything I need three facts: the record type and current TTL, who resolves the name (public resolvers, a corporate resolver, or internal clients I control), and whether clients hold long-lived connections. Assuming a public A record for api.example.com, TTL 3600, third-party resolvers I don't control, and a new load balancer already provisioned: the plan is: shorten TTL, wait out the old TTL, swap the record in one change, watch per-resolver answer cohorts, and keep the old endpoint serving until connection tails drain.

The plan, with the arithmetic

WhenActionWhy
T-1hSet TTL 3600 → 60 on the A record3600s is the longest a resolver may hold the old answer
T-1h to T-0Wait 3600s, then confirm caches have expiredAny cache that fetched at T-1h+ε still holds the old record until T+3600s
T-0Swap the address in a single changeOne change avoids an NXDOMAIN window
T-0 to T+60sExpect compliant resolvers to convergeNew TTL is 60s
T-0 onwardWatch old-IP query share per resolverStragglers show as a nonzero cohort
until drainedKeep old LB upTCP/keep-alive outlives DNS TTL

Verify the TTL actually propagated before the swap: dig +noall +answer api.example.com against the authoritative server, then against a public resolver, and check the answer's TTL is counting down from 60, not 3600.

Why the mechanism matters

A resolver may reuse an answer for exactly its TTL, so lowering the TTL only helps future lookups. If you lower it and swap immediately, resolvers that fetched one second earlier still hold the old address for the full 3600s. That's the whole reason for the one-old-TTL wait.

Negative caching is the trap. If you delete the old record before adding the new one, resolvers cache NXDOMAIN for the SOA minimum (commonly 300–3600s), so clients keep failing after the new record exists. Always swap in one change; never delete-then-add.

Connection tails are the second trap. DNS TTL bounds name resolution, not established connections. HTTP keep-alive is typically 60–300s, but gRPC streams and WebSockets can run for hours. Measure the p99 connection duration on the old LB and keep it serving until active connections fall to zero.

Alternatives and when to pick them

  • DNS-level weighting (e.g. Route 53 weighted records): shift 10% → 50% → 100% by changing weights, no per-step TTL wait, and rollback is a weight change. Costs: both endpoints must be live simultaneously, and weighted answers are per-query, so a client can flip between endpoints. Bad for stateful sessions.
  • Big-bang with a short TTL is acceptable when you control all resolvers (internal clients), the TTL is already short, or there's no session affinity. It's the wrong choice for a public name behind unknown resolvers.

Failure modes and detection

  • Resolver ignoring TTL: some corporate resolvers, and the JDK with a security manager installed (networkaddress.cache.ttl = -1, cache forever). Detect via per-resolver query counts still hitting the old IP; mitigate by keeping the old endpoint up.
  • Negative-cache poisoning: detect an NXDOMAIN rate spike in resolver logs; prevent by swapping atomically.
  • Certificate mismatch on the new endpoint: pre-check with openssl s_client -connect 198.51.100.20:443 -servername api.example.com; detect via TLS handshake failures in LB logs.
  • Connection tails: detect via active-connection count on the old LB.

Rollback

Revert the A record to the old address. With TTL 60, rollback converges in about 60s for compliant resolvers; the old LB is still warm, so no capacity rebuild. Restore TTL 3600 only after the old-IP cohort is zero for a full TTL window.

Curated: · Written: · Reviewed:

Difficulty: Medium
Q&A-5

Diagnose a newly created record that some users still cannot resolve.

Answer

Let me clarify the scenario. A record was created in an authoritative zone, say api.example.com A 203.0.113.5, and some users still get NXDOMAIN or NODATA while others resolve it. I'll assume we control the authoritative servers and can query them directly. The first thing I'd do is confirm the exact failure mode with dig.

Run dig @8.8.8.8 api.example.com A and dig @ns1.example.com api.example.com A. If the authoritative server returns the record but the resolver returns NXDOMAIN, the resolver has a negative cache entry. Negative caching is defined in RFC 2308: resolvers cache NXDOMAIN and NODATA for the SOA minimum TTL. That value is the last field in the SOA record, often 3600 seconds (1 hour) by default, but can be set to 300 or even 86400. So if a user queried before the record existed, they'll keep getting NXDOMAIN until that TTL expires. Some resolvers cap this: BIND's max-ncache-ttl defaults to 10800 seconds (3 hours), so even a large SOA minimum won't exceed that.

To confirm, check the SOA in the authority section of the negative response: dig @8.8.8.8 api.example.com A +noall +authority. You'll see something like example.com. 3600 IN SOA ns1.example.com. hostmaster.example.com. 2024051501 7200 3600 1209600 3600. The last number is the negative TTL. Compare with the authoritative SOA: dig @ns1.example.com example.com SOA. If the serial is the same, the zone is current.

Other causes: stale secondary. If you have a hidden primary and secondaries, check the serial on each: dig @ns1.example.com example.com SOA and dig @ns2.example.com example.com SOA. If ns2 has an older serial, it hasn't transferred the new record. Detection: serial mismatch. Cost: users hitting ns2 get NXDOMAIN. Fix: force zone transfer or fix notify/allow-transfer.

Split-horizon views: if the record was added to the internal view but not the external, users on the wrong view get NXDOMAIN. Detection: query the same name from different source IPs or against different resolver IPs that map to different views. Cost: external users can't resolve.

DNSSEC: if the record is signed but the signature is expired or the DS record is missing, validating resolvers return SERVFAIL. Detection: dig +dnssec @8.8.8.8 api.example.com A and check for the AD flag; if SERVFAIL, run dig +dnssec +cd @8.8.8.8 api.example.com A to bypass validation and see if the record exists. Cost: entire zone may fail validation for all names.

Client/application caches: Java caches DNS for 30 seconds by default (networkaddress.cache.ttl), but can be set to -1 (infinite). OS caches like systemd-resolved or nscd. Detection: flush and retry. Cost: only affects that client.

Now, trade-offs: wait vs flush. Waiting is safe but slow. If the negative TTL is 3600 seconds, you wait up to an hour. If it's 86400, you wait a day. Flushing is fast but risky. You can only flush caches you control. For BIND, rndc flushname api.example.com; for Unbound, unbound-control flush api.example.com. But flushing a shared resolver affects all users and can cause a load spike on authoritative servers. Also, many public resolvers like 8.8.8.8 don't allow flushing. So the decision: if the negative TTL is short (< 300s) and impact is low, wait. If impact is high and you control the resolver, flush selectively. If you don't control it, you must wait or ask users to switch resolvers.

Failure modes: Negative caching persists because resolvers honor SOA minimum; detection is the SOA in the negative response. Operational cost: delayed rollout. Stale secondary: detection by serial comparison; cost: inconsistent answers. View misconfiguration: detection by querying from different networks; cost: users in wrong view can't resolve. DNSSEC: detection by SERVFAIL and DNSSEC debug; cost: entire zone may fail validation.

Prevention: order record creation before dependent rollout. But more specifically, lower the negative TTL before a planned change. For example, set SOA minimum to 300 seconds a day before, then create the record, then restore. Also ensure secondaries are in sync before announcing. And test from multiple resolvers.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-2

Diagnose a lame DNS delegation.

Answer

What a strong candidate says in the first 60 seconds

A lame delegation is not 'DNS is broken'. It means the parent zone publishes an NS record for the zone pointing at a server that does not serve that zone authoritatively. Only the lookups that land on that server fail; the rest resolve normally, so the symptom is a fat tail of SERVFAILs and slow retries, not a clean outage.

Two things look identical to a user and have to be ruled out first:

  • DNSSEC bogus: the parent has a DS that the child's DNSKEY does not match, so validating resolvers SERVFAIL while the zone itself answers fine.
  • Plain unreachability: the server is healthy, my path to it is not.

Assumptions I state out loud: I know the zone name, I can query the parent's nameservers directly, and I can reach the child on 53/udp and 53/tcp.

1. Read the delegation the parent actually publishes

dig +norec @a.gtld-servers.net example.com NS
example.com.      172800 IN NS ns1.example.com.
example.com.      172800 IN NS ns2.example.net.
ns1.example.com.  172800 IN A  192.0.2.1      ; glue, ADDITIONAL section
;; ns2.example.net is out of bailiwick: no glue, resolve it separately

+norec keeps my own resolver's cache out of the picture. That 172800 s (48 h) NS TTL is the budget the whole repair has to respect.

2. Ask every advertised nameserver directly

dig +norec @192.0.2.1 example.com SOA
;; ->>HEADER<<- opcode: QUERY, status: REFUSED, flags: qr; ANSWER: 0    <- lame

dig +norec @198.51.100.5 example.com SOA
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, flags: qr aa; ANSWER: 1
example.com. 3600 IN SOA ns1.example.com. hostmaster.example.com. (
             2024051201 7200 3600 1209600 3600 )

Three things discriminate, in this order: the rcode (REFUSED or SERVFAIL versus NOERROR), the aa flag (NOERROR with no aa means it answered from cache or for a different zone. Still lame), and whether the SOA and the apex NS RRset match what the parent published. Repeat over TCP with dig +tcp: a server can be fine on UDP and lame on TCP, and a truncated UDP answer hides that. If DNSSEC is in play, compare dig +norec @parent example.com DS against dig +dnssec @ns example.com DNSKEY, or run the name through dnsviz or Zonemaster.

3. Symptom to cause

what I seecauseconfirm with
NS at the parent, no A/AAAA in ADDITIONAL for an in-bailiwick NSglue missing: a resolver cannot bootstrap the address, it deadlocksdig +norec @parent example.com NS +additional
the glue address answers REFUSED or SERVFAILzone not loaded on that server (config, view, ACL)named-checkzone example.com db.example, then reload; rndc showzone
NOERROR with no aa flagit answered as a cache, or for a different zonedig +norec @ns example.com SOA, read the flags line
apex NS RRset differs from the parent'sstale delegation left by an unfinished rolloverquery NS at the child and at the parent, diff the sets
one nameserver reports a lower SOA serialsecondary not refreshing: notify blocked or primary ACL wrongcompare SOA serial on every NS; watch the 1209600 s expire
direct +norec works but browsers failDNSSEC bogus, not lameDS at the parent versus DNSKEY at the child, or dnsviz

4. Fix, and how to sequence it

A wrong delegation is repaired at the parent, via the registrar UI or an EPP/registry update; the child cannot clear a stale NS or bad glue. A server that does not load the zone is repaired at the child; editing the parent instead hides the fault and moves it to whichever server inherits the record.

Then pick the sequence against the TTL budget. Rolling: add the new NS at the parent, wait past the 172800 s NS TTL (three days), then withdraw the old one: keeps answering servers alive at every instant, so no resolver is ever holding a set that contains a dead entry. A one-shot atomic cutover only wins when the old server already answers nothing.

Two traps. Leaving the decommissioned IP in the parent: that entry is itself a lame delegation and outlives your change by the full TTL. And declaring victory because your laptop resolves: your resolver is probably pinned to the healthy nameserver. Re-run step 2 against every advertised NS from a second network, and re-read the parent's answer, because the parent's copy is what everyone else sees.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-3

Review a DNS delegation and glue change.

Answer

A delegation change is safe only if three things agree (the parent's NS set, the parent's glue, and the child's apex NS set) and the new nameservers are already answering authoritatively before the parent points at them. So the review has one decision to make: is the change ordered so no resolver is ever handed a nameserver it cannot reach? TTLs, DS and rollback are bookkeeping around that.

Why glue exists. Glue is an address record in the parent zone for a nameserver whose name sits at or below the child. If example.com is served by ns1.example.com, a resolver asking the .com servers for example.com gets NS ns1.example.com and, without glue, must resolve ns1.example.com, which means asking example.com's nameservers. Circular. The parent breaks it by shipping A/AAAA next to the NS. If the nameserver is out-of-bailiwick (ns1.hosting.net), no glue is needed or allowed; the resolver resolves it through the normal chain. That one rule tells you which targets in the change need glue.

What I check, with figures (example values):

RecordWhereExampleBreaks if wrong
parent NS.com zonens1/ns2.example.comresolvers never find the child
glue A/AAAA.com zone203.0.113.10, 2001:db8::10in-bailiwick NS unreachable
child apex NSexample.com SOAsame two nameslame delegation
DS.com zonekey tag 12345, alg 13SERVFAIL from validators

Order and TTL arithmetic. Stage the new nameservers with the zone loaded and answering for the apex and for the in-bailiwick NS names, then add parent delegation and glue. Keep the old nameservers answering for at least the old NS RRset TTL. At .com the NS TTL is 172800 s (2 days); a child NS TTL is often 3600 s; SOA minimum (negative-cache TTL) is commonly 86400 s. So a resolver that cached the old delegation can keep using it for up to 2 days: "until caches expire" means ≥ 172800 s, and if you also delete old glue, add its TTL. If you want a faster rollback, drop the child NS TTL to 300 s a day before the cutover; you cannot easily lower the parent's.

Verify from several vantage points. dig @a.gtld-servers.net example.com NS +norecurse for the parent view; dig @a.gtld-servers.net ns1.example.com A +norecurse for glue; dig @203.0.113.10 example.com SOA for authority; dig @8.8.8.8, @1.1.1.1 and @9.9.9.9 for the recursive view, both A and AAAA; delv @8.8.8.8 example.com for validation.

Failure modes and how I'd catch them.

  • DS/DNSKEY mismatch: every validating resolver returns SERVFAIL, so it is a total outage for validating clients. Catch it with delv or dig +dnssec before the parent change.
  • Stale glue: parent glue IP differs from the authoritative A. Compare dig @gtld ns1.example.com A +norecurse against dig @ns1.example.com ns1.example.com A. Cost: resolvers time out on the dead IP and fall through to the next NS.
  • Missing AAAA glue: IPv6-preferring resolvers fail. Query AAAA at the parent.
  • Partial provider failure: one of N nameservers not updated. Query each NS IP directly.
  • Lame delegation: child NS answers without the AA flag. Check the AA bit.

Trade-offs. In-bailiwick keeps everything under your control but you must maintain glue; out-of-bailiwick offloads that but adds a dependency on another zone. Lowering TTL before the change buys fast rollback at the cost of query volume: worth it for a risky cutover. When decommissioning with DNSSEC, remove the DS from the parent before removing the child's DNSKEY, or validators SERVFAIL; when adding, publish the DNSKEY first, then the DS.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-9

Diagnose DNS that works for small answers but fails for DNSSEC or large records.

Answer

What I'd say first

Assume a stub client behind a recursive resolver, authoritative servers behind that, and UDP/53 working for small answers. The split is almost always one of two things: the answer no longer fits the transport, or the transport that would carry it is blocked.

Small answers fit the classic 512-byte UDP limit and come back fine. Large answers (DNSSEC-signed RRsets, DNSKEY, ANY, many-record responses) exceed the advertised EDNS buffer. The server then either sets TC=1 and makes the client retry over TCP, or, if you advertised a big buffer like 4096, sends a fragmented UDP datagram that a firewall or NAT drops. Those two look different on the wire, and that's the first fork in the diagnosis.

The decisive test

Run the same query three ways (illustrative trace):

$ dig +dnssec +bufsize=512 example.com DNSKEY @192.0.2.53
;; flags: qr rd ra tc; QUERY: 1, ANSWER: 0, ADDITIONAL: 1
; EDNS: version: 0, flags: do; udp: 512
;; MSG SIZE  rcvd: 48

$ dig +dnssec +tcp example.com DNSKEY @192.0.2.53
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, ADDITIONAL: 1
;; MSG SIZE  rcvd: 1234

$ dig +dnssec +bufsize=4096 example.com DNSKEY @192.0.2.53
;; connection timed out; no servers could be reached

Read it like this:

  • tc flag set, small response → the server truncated because the answer didn't fit. Expected, not a fault by itself.
  • Same query over TCP returns the full 1234-byte answer → UDP truncation is the issue and TCP works. If the client never retries over TCP, or TCP/53 is blocked, resolution fails here.
  • +bufsize=4096 times out with no tc flag → the large UDP response was fragmented and dropped. No response at all is the fragmentation signature; a tc response is the truncation signature.

Why the sizes

IPv4 over Ethernet: 1500 MTU − 20 IP − 8 UDP = 1472 bytes of UDP payload. Advertise 4096 and the server may send 4096, split into three IP fragments; a stateful firewall that doesn't reassemble drops the whole datagram if any fragment is lost. IPv6's minimum MTU is 1280, so 1280 − 40 − 8 = 1232: that's why 1232 is the recommended EDNS buffer size and the default in current BIND and Unbound. A 2048-bit RSA DNSKEY is ~260 bytes of key material; two keys plus an RRSIG run well past 512, which is why DNSKEY queries are the classic trigger.

Failure modes and how to catch each

SymptomCauseConfirm with
tc on every DNSSEC query, client hangsTCP/53 blockeddig +tcp times out, dig +notcp returns tc
Large query times out, no tcFragments dropped / PMTUD black hole+bufsize=4096 fails, +bufsize=1232 succeeds
Response OPT shows udp: 512 though you sent 4096Middlebox stripped EDNS OPTcompare sent vs returned OPT
TCP works once, fails under loadresolver TCP limits (tcp-idle-timeout, connection cap)ss -s, resolver logs
ANY/DNSKEY truncated or droppedresponse rate limiting / amplification controlsRRL counters

Trade-off

Raising the EDNS buffer only helps if the path actually carries it. If you can't verify PMTUD end-to-end, keep 1232 and let TCP carry the genuinely large answers: that's the designed fallback. Going to 4096 buys fewer TCP retries at the cost of fragmentation risk you can't see. Don't disable DNSSEC to make the symptom go away; that hides the transport fault.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-7

Plan a safe DNSSEC signing and rollover.

Answer

Assume we control the zone and can edit the DS at the registrar, and that a validator must be able to build a chain of trust at every instant. That single constraint drives the whole plan.

Signing. Split the keys. A KSK (flags 257) signs only the DNSKEY RRset; a ZSK (flags 256) signs everything else. Use ECDSAP256SHA256 (algorithm 13): RFC 8624 recommends it and Ed25519 (15); keep RSASHA256 (8) only if a downstream needs it, and never SHA-1. Sign with a 14-day validity and re-sign every 5 days (RFC 7583 suggests re-signing at a third to a half of validity). DNSKEY TTL 3600, DS TTL 86400, SOA/NSEC TTL 3600. Denial: NSEC3 with 0 iterations and an empty salt, per RFC 9276.

Why order matters. A validator fetches the DS from the parent, matches it to a DNSKEY in the child, then verifies RRSIGs. If the DS exists but the matching DNSKEY does not, the answer is bogus and every validating resolver returns SERVFAIL. If the DNSKEY exists but there is no DS, the delegation is insecure: it still resolves, just unsigned. So the safe direction is always: publish the new key before the parent points at it, and remove the parent's pointer before you remove the key. Each wait is the relevant TTL plus propagation.

ZSK rollover: pre-publish. Add the new ZSK to the DNSKEY RRset, wait DNSKEY TTL + propagation (~2h at 3600), switch signing to the new ZSK, then wait the full RRSIG validity (14 days) so old signatures drain from caches before removing the old ZSK. Double-signature instead signs with both ZSKs at once: no pre-publish wait, but it doubles RRSIG and zone size. Pick it when you cannot tolerate the wait.

KSK rollover: double-DS. Publish the new KSK, add its DS at the parent, wait DS TTL + propagation (~1 day at 86400), switch the DNSKEY RRset to be signed by the new KSK, then remove the old DS, wait again, and remove the old KSK. Double-KSK keeps one DS but needs two KSKs published and both signing the DNSKEY RRset. Choose double-DS when the registrar supports multiple DS records; double-KSK when it does not.

stageactionwait before next
ZSK pre-publishadd new ZSK to DNSKEYDNSKEY TTL + propagation (~2h)
switch signing to new ZSKmax RRSIG validity (14d)
remove old ZSK—
KSK double-DSpublish new KSK, add DSDS TTL + propagation (~1d)
sign DNSKEY with new KSKDS TTL + propagation
remove old DS, then old KSK—

Failure modes and detection. DS without DNSKEY gives bogus/SERVFAIL for all validating resolvers: detect with dig +dnssec and check the AD flag, or DNSViz/Zonemaster, and alert when AD=0 on a zone you expect signed. Expired RRSIG gives the same SERVFAIL but only for validators, so it hides behind non-validating resolvers: monitor the RRSIG expiration field and alert before expiry. Signer clock skew produces not-yet-valid or expired signatures: monitor NTP on the signer. Oversized responses force TCP fallback: keep the EDNS buffer at 1232 (DNS flag day 2020) and test with dig +bufsize. A secondary that stops re-signing leaves stale signatures: compare serial and RRSIG inception across every secondary.

Rollback. Keep the old keys and DS state until the new chain validates from several resolvers (for example 8.8.8.8, 1.1.1.1, and a local unbound).

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-8

Choose and govern encrypted DNS for managed clients.

Answer

Core answer (first 90 seconds). Two decisions, not one: which encrypted transport and resolver you standardise on, and what the client does when that resolver is unreachable. I'd standardise on DoT (RFC 7858, TCP 853) for managed laptops and phones, because Android Private DNS, iOS/macOS configuration profiles and Windows 11 all configure it natively and it's a single port to allow at the firewall. I'd use DoH (RFC 8484, HTTPS 443) only where DoT is blocked or where you want the traffic to blend with web. I would not point clients at a public resolver. I'd run our own validating resolver (Unbound, Knot Resolver or BIND) behind a DoT/DoH front end, so DNSSEC validation and query logging stay under our control and internal zones still resolve. Fail-closed, with an explicit exception path for captive portals.

Why. DoT is a TLS stream on 853; DoH is HTTP/2 or HTTP/3 on 443; DoQ is QUIC on UDP 853 (RFC 9250). The port matters for governance: 853 is easy to allow only to your resolver and block everywhere else, while 443 is indistinguishable from web traffic, so a browser or app with its own DoH can bypass you silently. Bootstrap is the trap: the client needs the resolver's IP before it can resolve the resolver's name, so you hardcode the anycast IP (1.1.1.1, 9.9.9.9, or your own) alongside the hostname.

DoTDoHDoQ
PortTCP 853TCP 443UDP 853
RFC785884849250
OS configAndroid Private DNS, iOS/macOS profiles, Win11Win11, browserslimited
Firewallone port, easy allowlistblends with webUDP, often blocked
Governancevisiblebypassablevisible-ish

DNSSEC. Validation belongs at the recursive resolver, not the stub. A public DoH resolver returns the AD bit but you're trusting its validation. Running your own validator lets you expose status, query a known-bad name like dnssec-failed.org and alert if it resolves, and log failures.

Fail-closed. Android Private DNS "strict" and Windows udpfallback=no both fail closed. The cost is captive portals: the client can't resolve the portal's login page, so the OS reports no internet. Mitigation: allow plaintext 53 to the portal's resolver during portal detection, or let the OS's own probe (Windows NCSI, Apple captive.apple.com) run unencrypted. Firefox's use-application-dns.net canary domain tells it to disable DoH on such networks.

Split DNS. Public DoH breaks split-horizon. Fix: point clients at your own DoH/DoT front end that forwards internal zones to AD DNS, or use Windows NRPT rules to exclude internal suffixes from encryption. macOS/iOS profiles support supplemental match domains for the same purpose.

Governance. Lock the setting with MDM, allowlist resolvers, and block outbound 53/853/443 to anything else at the firewall. Log which resolver each client uses. Jurisdiction matters: Cloudflare and Google publish retention policies; if you need EU-only processing, run your own or get a data-processing addendum.

Failure modes and detection.

  • Captive portal: portal probe fails, "no internet". Detect: spike in portal-probe failures. Fix: allowlist probe domains.
  • Resolver outage: fail-closed means total outage. Detect: resolver health checks, query success rate. Fix: two anycast IPs, both must be up.
  • Certificate expiry: TLS handshake fails. Detect: cert expiry monitoring, handshake failure rate. Fix: automate renewal, pin the CA not the leaf.
  • Clock error: TLS validation fails. Detect: NTP sync monitoring. Fix: NTP before DNS.
  • Proxy interception: TLS inspection breaks DoT/DoH. Detect: MITM cert in handshake failures. Fix: exclude 853/443 to resolvers from inspection.
  • Application bypass: browser/app DoH. Detect: firewall logs on 443 to known DoH IPs. Fix: block, or canary domain.

Config. Windows 11: netsh dns add encryption server=1.1.1.1 dohtemplate=https://cloudflare-dns.com/dns-query autoupgrade=yes udpfallback=no. Android: Private DNS hostname dns.example.com (strict). Both are real, documented settings.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-10

Design split DNS for remote and office clients.

Answer

Core answer (first 90 seconds)

Assume one public zone example.com and one internal zone corp.example.com, office clients on 10.0.0.0/8, remote clients on a VPN. The goal: office and remote clients get the same private answers, public clients never see them, and no private answer lands in a cache you don't control.

Run split-horizon at the internal authoritative, not the public one. The public example.com zone holds only public records, served by a public-facing authoritative (NSD or BIND on a DMZ host). The internal zone corp.example.com is served by an internal authoritative reachable only from 10.0.0.0/8 and the VPN pool. Remote clients get a VPN-pushed resolver, OpenVPN push "dhcp-option DNS 10.0.0.53", and that resolver (Unbound) conditionally forwards corp.example.com to the internal authoritative.

Mechanism

Split-horizon means one name has two authoritative sources. The danger isn't the split; it's a private answer escaping into a cache you don't own. If git.corp.example.com → 10.20.5.7 is ever served to a public recursive resolver, that A record sits in its cache for the full TTL and is handed to anyone who asks: leaking internal topology and returning an address they can't reach. Keeping the private zone on a host that only answers 10.0.0.0/8 and the VPN pool prevents that.

DNSSEC is where split-horizon bites. If a name exists in both zones with different data, a validating resolver holding the public chain sees a signed RRset that doesn't match the private answer and returns SERVFAIL. So don't sign the private view with the public chain: leave the private zone unsigned, or run a separate internal trust anchor.

Choosing the mechanism

ApproachRuns onDecides byFails when
BIND view + match-clientsinternal authoritativeclient source IPa remote client's source IP matches no view and falls to the default
Conditional forwarding (Unbound forward-zone, dnsmasq server=/corp.example.com/10.0.0.53)internal recursive resolverquery name suffixthe client uses a resolver that isn't yours
VPN-pushed resolverclient stubtunnel configsplit tunnel plus browser DoH bypasses it

I'd combine the first two: views for office, conditional forwarding for remote. Pushing a resolver alone is the weakest option because it's client-side and easy to bypass.

Trace: remote laptop asks for git.corp.example.com

  1. Stub resolver sends to 10.0.0.53, pushed by the VPN.
  2. Unbound matches forward-zone: name: "corp.example.com" and forwards to 10.0.0.10.
  3. Internal authoritative returns A 10.20.5.7, TTL 60.
  4. If the laptop instead used DoH (Firefox's default Cloudflare provider, or Chrome's secure-DNS setting), the query goes to 1.1.1.1 over HTTPS, hits the public zone, and gets NXDOMAIN, or a stale public record.

Failure modes and detection

  • DoH bypass: browser resolves privately, gets NXDOMAIN, user reports "site down." Detect by comparing dig @10.0.0.53 git.corp.example.com against the browser's result; block DoH resolvers at the edge if policy allows.
  • Captive portal: hotel DNS answers everything with its own IP. Detect with dig +trace from the client.
  • Overlapping suffixes: if corp.example.com is internal but example.com is public, a query for foo.corp.example.com that the internal zone doesn't own leaks to the public parent. Make the internal zone authoritative for the whole suffix.
  • Stale caches: keep private TTLs low (30–60s) so a failover change propagates in a minute, versus up to an hour on a 3600s public TTL.

Test before, during and after VPN connect, across sleep/roam, and after resolver failover.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-11

Use mDNS without conflicting with enterprise DNS.

Answer

What I'd say first

The conflict is a namespace collision, and the fix is a hard boundary: enterprise DNS never serves or forwards .local, and mDNS never leaves the local link. RFC 6762 reserves .local for multicast DNS, and RFC 6761 lists it as a special-use name, so a recursive resolver should refuse or answer NXDOMAIN rather than forward it upstream. mDNS itself is UDP 5353 to 224.0.0.251 (IPv4) and ff02::fb (IPv6), sent with IP TTL 255. A receiver can check that value to confirm the packet originated on-link, since a router would have decremented it. Everything else (AD zones, split-horizon views, search domains) stays in unicast DNS.

Assumptions: I control the enterprise resolvers and the DHCP option 119 search list; devices are on one L2 segment unless I say otherwise.

Mechanism

A responder claims a name by probing: three probe queries 250 ms apart, carrying the proposed records in the Authority section, from source port 5353. If no conflicting answer arrives, it announces: two to eight unsolicited responses with doubling intervals starting at 1 s. If a conflict does arrive, the tie-break is a lexicographic comparison of the record rdata; the loser renames (typically appending -2) and re-probes. That is why duplicate names self-heal on a flat link but not across a routed one.

Record lifetimes decide how fast the enterprise notices a change:

RecordTTLNotes
A/AAAA, SRV, PTR (host name)120 sshort, so moves are seen quickly
PTR/SRV/TXT (service)4500 s75 min
cache-flush bittop bit of rrclassunique records overwrite cache

The cache-flush bit is the part people miss: for unique records (A, AAAA, SRV) the responder sets the top bit of the class field so caches replace rather than accumulate. Shared records, like PTR service enumeration, do not set it.

Trade-offs and when not to use it

mDNS is right when devices share a link and you don't want to run a naming authority. It is wrong the moment you need cross-subnet discovery, per-user access control, or an audit trail: multicast does not route, and a reflector (Avahi's, for example) re-broadcasts across boundaries and leaks names into segments you never intended. The governed alternative is a discovery proxy (RFC 8766), which answers unicast DNS-SD queries for remote links, or simply publishing unicast SRV/TXT records in enterprise DNS.

Failure modes

  • Duplicate names: two hosts probe the same name; the tie-break renames one. Detected by -2 suffixes appearing in discovery output.
  • VPN/split-tunnel: the VPN adapter is a second multicast domain, so a name resolves on one interface and not the other. Detected with interface-scoped queries.
  • Sleep/wake and network move: cached records with a 120 s TTL go stale; the host re-probes on the new link.
  • Hostile announcements: anyone on the link can claim a name or answer for it. MDNS has no authentication. Detected by diffing announced records against your inventory.
  • Multicast suppression: some Wi-Fi APs drop or rate-limit multicast, so discovery silently fails. Detected when unicast fallback works and multicast does not.

The boundary rule

Configure resolvers to refuse .local instead of forwarding it, keep .local out of the search list, and if you must cross subnets, use a discovery proxy rather than a reflector.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-22

Design DNS observability and SLOs.

Answer

Clarify first. Which tier am I instrumenting? Stub, recursive, and authoritative have different SLIs and different owners. I'll assume a recursive fleet (Unbound 1.19 or BIND 9.18) serving internal clients, an authoritative fleet (BIND 9.18 or NSD 4.x) for our own zones, and anycast, so every SLO is measured per PoP, not fleet-wide.

The SLOs.

TierSLISLO over 30 days
Recursive% queries answered with a non-SERVFAIL rcode within 2 s99.95% (error budget 21 m 36 s)
Recursivep99 recursion time on cache miss< 500 ms
Recursivep99 response on cache hit< 10 ms
Recursivecache hit ratio, steady state> 80%
Authoritative% queries answered, any rcode, per zone99.99%
Authoritativezone serial visible at every vantage pointwithin 5 min of publish
Stub / RUM% client resolutions that succeed99.9%

Arithmetic: 30 days is 43,200 minutes, so 0.05% is 21.6 minutes of budget. That is the number you defend in a review, not "high availability".

Why the tail behaves this way. Without EDNS0 the UDP payload is capped at 512 bytes (RFC 1035); EDNS0 (RFC 6891) advertises a larger buffer, and DNS Flag Day 2020 settled on 1232 bytes to stay under the 1280-byte IPv6 minimum MTU and dodge fragmentation. When the answer does not fit, the server sets TC=1 and the client must retry over TCP: an extra handshake plus RTT. A truncation storm therefore shows up as a p99 spike and a jump in num.query.tcp (Unbound) or the TCP counter in BIND's statistics-channels JSON.

Cache age drives the other tail. When a hot name's TTL expires under load, the next N queries all miss and recurse at once. Unbound's prefetch: yes refreshes popular records before expiry, and serve-expired (RFC 8767) serves stale when upstreams fail. Detect the stampede as a hit-ratio drop plus a shift in the recursion-time histogram.

Negative caching is the trap. NXDOMAIN is cached for the SOA minimum, capped by BIND's max-ncache-ttl default of 10800 s (3 h) and Unbound's cache-max-negative-ttl default of 3600 s. A wrong NXDOMAIN sticks for hours, so alert on NXDOMAIN rate by zone, not just SERVFAIL.

Trade-offs. Passive collection (dnstap, unbound-control stats_noreset, BIND statistics-channels, Knot Resolver's Prometheus endpoint) sees real traffic but is blind to stub-side failures. Active probes (RIPE Atlas, internal synthetic queries) catch delegation and DNSSEC breakage but not the real traffic mix. Client RUM catches the last mile. Use passive as the SLO source of truth and active as a canary. dnstap at 100k qps is heavy: sample 1%, or log only QTYPE, rcode and latency and hash the QNAME, because full query names are browsing history.

Failure modes and detection.

  • DNSSEC bogus (expired RRSIG, missing DS) returns SERVFAIL. Detect via num.answer.bogus and SERVFAIL rate per zone; confirm with delv from a probe. Cost: every validating client fails.
  • An authoritative server down makes the resolver retry; per-server RTT in Unbound's infra-cache climbs and SERVFAIL rises.
  • A fragmentation blackhole drops large UDP responses; timeouts correlate with response size.
  • A serial that never propagates serves stale data; poll SOA from multiple vantage points and alert on divergence.

Segment every metric by QTYPE, view, resolver, region and address family, and correlate with connection outcomes, but keep the QNAME out of the log unless policy allows it.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-25

How would you detect and contain DNS tunneling and data exfiltration from query behavior?

Answer

Start with the recursive resolver's query log, because it is the only place where QNAME, QTYPE, client and response size appear together. Tunneling shows up as a shape rather than a single query: one client, one authoritative zone, many unique subdomains, long high-entropy labels, and a QTYPE mix skewed to TXT, NULL or CNAME. Legitimate high-volume resolvers look the opposite: high cardinality spread across many zones, short readable labels, almost all A/AAAA.

Four signals, baselined per client and per zone:

  • Label length and entropy. RFC 1035 caps a label at 63 octets and a full name at 255. Base32-encoded payloads push labels to 40-63 characters with near-uniform character distribution. Shannon entropy per label: normal hostnames cluster below roughly 3.2 bits/char, encoded payloads sit above 4.5.
  • Unique-subdomain cardinality. Distinct QNAMEs per (client, zone) per 5 minutes. A workstation resolving 500+ unique names under a zone it has never touched is the strongest single indicator.
  • QTYPE distribution. TXT and NULL carry arbitrary bytes; CNAME abuse hides data in the target. A client whose TXT share jumps from 0.1% to 30% deserves a look.
  • Volume and asymmetry. Queries per second per client, plus response bytes per query.

Telemetry: resolver query logs (BIND/Unbound/Knot with qname, qtype, rcode, client, response size), passive DNS, authoritative logs for the target zone, Zeek/Suricata dns.log, flow records for byte counts, and DHCP lease logs (RFC 2131) to map client IP back to MAC and hostname for attribution. If clients use DoT or DoH (RFC 7858, RFC 8484) the QNAME never reaches your resolver, so endpoint DNS telemetry or a managed resolver is the only visibility you have.

Separating legitimate traffic: CDNs, mail gateways, scanners and monitoring also produce high cardinality, but across many zones with stable label structure. Tunneling concentrates on one zone, often recently registered, with an effectively random label set. Baseline for a week and alert on deviation, not absolute counts.

Containment, least disruptive first: add the zone to an RPZ or blocklist and sinkhole it; apply response rate limiting on the resolver for that client or zone; disable recursion for the offending client; then quarantine the endpoint. Move the switch port to a restricted VLAN and let DHCP hand it a remediation scope. Capture the query log and the endpoint's process list before cutting it off.

Failure modes: entropy alone flags DKIM, DMARC and ACME challenge names; volume alone flags the CDN. You need the per-zone cardinality join to tell them apart. And a tunnel over DoH to a public resolver is invisible in your logs: you catch it from flow bytes and endpoint telemetry, not QNAMEs.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-12

Trace DHCPv4 address acquisition across a relay.

Answer

A DHCPv4 exchange across a relay is four messages (Discover, Offer, Request, ACK) but the relay is what makes scope selection work. The server never sees the client's subnet, so it reads the relay's giaddr and picks the pool from that. Option 82 (RFC 3046) rides along for per-port policy; it is not what selects the pool.

Assumptions for the trace: one RFC 3046-capable relay, server reachable by routed unicast, client on VLAN 30 = 10.20.30.0/24, relay SVI 10.20.30.1, helper address 10.0.0.10, client MAC 00:1a:2b:3c:4d:5e, xid 0x3d1e4f7a, broadcast flag set.

Eight frames, four messages. Each message crosses the relay twice:

#L2 src → dstIP src:port → dst:portoptypegiaddrhopsflags
100:1a:2b:3c:4d:5e → ff:ff:ff:ff:ff:ff0.0.0.0:68 → 255.255.255.255:6711 Discover0.0.0.000x8000
200:1b:0c:1e:30:01 → 00:50:56:aa:bb:cc10.20.30.1:67 → 10.0.0.10:6711 Discover10.20.30.110x8000
300:50:56:aa:bb:cc → 00:1b:0c:1e:30:0110.0.0.10:67 → 10.20.30.1:6722 Offer10.20.30.110x8000
400:1b:0c:1e:30:01 → ff:ff:ff:ff:ff:ff10.20.30.1:67 → 255.255.255.255:6822 Offer10.20.30.110x8000
500:1a:2b:3c:4d:5e → ff:ff:ff:ff:ff:ff0.0.0.0:68 → 255.255.255.255:6713 Request0.0.0.000x8000
600:1b:0c:1e:30:01 → 00:50:56:aa:bb:cc10.20.30.1:67 → 10.0.0.10:6713 Request10.20.30.110x8000
700:50:56:aa:bb:cc → 00:1b:0c:1e:30:0110.0.0.10:67 → 10.20.30.1:6725 ACK10.20.30.110x8000
800:1b:0c:1e:30:01 → ff:ff:ff:ff:ff:ff10.20.30.1:67 → 255.255.255.255:6825 ACK10.20.30.110x8000

What the server reads. The Discover arrives at 10.0.0.10 with hops incremented and giaddr stamped. Hex dump of the 285-byte DHCP payload as the server sees it:

offset  bytes                                             field
0x000   01 01 06 01 3d 1e 4f 7a 00 00 80 00 00 00 00 00   op=1 htype=1 hlen=6 hops=1 | xid=0x3d1e4f7a | secs=0 | flags=0x8000 | ciaddr=0.0.0.0
0x010   00 00 00 00 00 00 00 00 0a 14 1e 01 00 1a 2b 3c   yiaddr=0.0.0.0 | siaddr=0.0.0.0 | giaddr=10.20.30.1 | chaddr=00:1a:2b:3c...
0x020   4d 5e 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ...4d:5e | sname (64 B, zero)
0x030–0x0EB  all 00                                        sname rest + file (128 B)
0x0EC   63 82 53 63                                       magic cookie
0x0F0   35 01 01 37 04 01 03 06 0f 3d 07 01 00 1a 2b 3c   opt 53=1 (Discover) | opt 55 len 4: 1,3,6,15 | opt 61 len 7: 01 00:1a:2b:3c...
0x100   4d 5e 52 18 01 0e 47 69 31 2f 30 2f 37 3a 56 4c   ...4d:5e | opt 82 len 24 | sub 1 len 14: "Gi1/0/7:VLAN30"
0x110   41 4e 33 30 02 06 00 1b 0c 1e 30 00 ff            "VLAN30" | sub 2 len 6: 00:1b:0c:1e:30:00 | end

The server reads giaddr = 10.20.30.1 at 0x018 and selects the 10.20.30.0/24 pool. Option 82 at 0x102 is 24 bytes: circuit-id Gi1/0/7:VLAN30 (sub-option 1, len 14) and remote-id 00:1b:0c:1e:30:00 (sub-option 2, len 6). It changes policy only if the server is configured to read it.

Offer. yiaddr 10.20.30.57, option 54 server-id 10.0.0.10, option 51 lease 86400 s, option 58 T1 43200, option 59 T2 75600, plus options 1/3/6/15. Sent to giaddr:67. The relay forwards to the client: broadcast if the broadcast flag is set, otherwise unicast to yiaddr/chaddr, and that unicast needs an ARP entry, which is exactly why the flag exists.

Request. The client broadcasts 255.255.255.255:67 with option 50 = 10.20.30.57 and option 54 = 10.0.0.10. It is broadcast so every server on the segment sees which offer won and the losers withdraw their reservations; the Offer itself can be unicast because the server already knows the client's chaddr. The relay stamps giaddr/82 again.

ACK. Server → relay → client on the same path. The client ARP-probes the address (RFC 5227), then binds.

Trade-offs. A relay lets one server serve many subnets with giaddr carrying scope, versus a server on every broadcast domain. Option 82 buys per-port policy and rate limiting but breaks if a downstream switch strips it or the server rejects unknown sub-options. A broadcast reply is safe but wakes every host; unicast needs ARP and fails if the client cannot answer.

Failure modes, with signatures.

  • No offer: relay shows Discover in, nothing out; server logs "no free leases" or an option-82 policy drop. Capture: same xid retransmitted, interval doubling to a 64 s cap (RFC 2131 §4.1), no reply.
  • Rejected request: DHCPNAK in the capture (client moved subnets, lease expired); client restarts at Discover.
  • Lost ACK: Offer and Request present, no ACK; client retransmits Request with the same xid. Usually MTU/firewall dropping the option-heavy ACK, or the relay cannot deliver (no ARP, broadcast flag clear).
  • Client config failure: ACK present but no bind: ARP probe conflict, or the client rejects the options.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-18

Detect and contain rogue DHCP.

Answer

Assumptions: Cisco-style access layer (IOS/IOS-XE), one legitimate DHCP server or relay reachable through a trusted uplink, endpoints on untrusted access ports. The numbers below are Cisco defaults: confirm them on your platform before quoting them.

Core answer (first 90 seconds). A rogue DHCP server wins by answering first: it hands the client a lease whose gateway and DNS point at the attacker, so the victim routes through them. Detect it by watching for DHCP server messages (OFFER/ACK/NAK) arriving on ports that should never carry them, and by correlating endpoint complaints by subnet. Contain it by enabling DHCP snooping so only trusted uplinks can emit server messages, then locate the offending port from the binding table and option 82 circuit ID before you shut anything.

Mechanism. DHCP snooping classifies every port trusted or untrusted. Untrusted ports may send client messages (DISCOVER/REQUEST), but the switch drops any OFFER/ACK/NAK that arrives on them: that alone kills a rogue server sitting on an access port. As legitimate ACKs pass, the switch records a binding: MAC, IP, lease, VLAN, port. That table is what IP Source Guard and Dynamic ARP Inspection consume, so snooping is the foundation, not just a filter.

Rate limit: ip dhcp snooping limit rate 15 is the Cisco default. 15 packets/sec per port; exceeding it err-disables the port. That stops a rogue client from exhausting the binding table or the DHCP pool.

Option 82: with ip dhcp snooping information option, the switch stamps the client's request with circuit ID (port + VLAN) and remote ID. A rogue server is usually a host on an access port, and that host's own DHCP client request carries its circuit ID, so the binding table plus option 82 ties the offending MAC to a physical port before you even inspect the server traffic.

Detection. Alert on server messages dropped on untrusted ports, binding entries whose server identifier isn't your relay, and rate-limit err-disables. Correlate endpoint reports (wrong gateway, captive portal, TLS failures) by subnet to size the blast radius.

Containment. Trace before you shut: read the binding table and CAM table for the rogue MAC, confirm the port, capture the OFFER/ACK (port mirror or debug ip dhcp snooping), then err-disable or shut the port. Preserve the pcap and the binding entry for the write-up.

Trade-offs. Snooping is per-switch and needs a trusted-port design. NAC (802.1X/MAB) stops the host reaching the wire at all but is heavier to deploy and doesn't cover guests. A DHCP-free access layer (static or SLAAC-only) removes the attack surface but breaks roaming clients. Baseline is snooping; add NAC where you control the endpoint; accept that neither covers a rogue plugged into a trusted uplink.

Failure modes.

  • A reload wipes the binding table (it lives in DRAM). Without ip dhcp snooping database flash:... (write delay default 300 s), IP Source Guard drops existing hosts until they renew: fail-closed. Decide deliberately: fail-closed is safer, but a reload becomes an outage.
  • Trusted-port sprawl: marking an AP or hypervisor uplink trusted lets a rogue behind it through.
  • Rate limit set too low err-disables legitimate ports during a broadcast storm.

Worked trace. Rogue laptop on Gi1/0/14 (VLAN 20) runs dnsmasq and offers 10.20.0.50/24 with gateway 10.20.0.1 (itself).

  1. Client DISCOVER → switch stamps option 82 circuit ID Gi1/0/14:VLAN20 → relay → real server.
  2. Rogue OFFER arrives on Gi1/0/14 (untrusted) → dropped and logged.
  3. Client never sees the rogue lease; it gets the real one via the trusted uplink.
  4. Binding table shows the client MAC → 10.20.0.x on Gi1/0/14; the rogue's own request shows the same port.
  5. Shut Gi1/0/14, capture, done.

Curated: · Written: · Reviewed:

Difficulty: Medium
Q&A-16

Review DHCP scope and option configuration.

Answer

Assumptions: ISC dhcpd/Kea or Windows Server, one /24 scope served directly or through a relay, mixed Windows/macOS/Linux clients. Numbers are ISC dhcpd defaults unless noted.

Core answer. Review in this order: scope arithmetic, option precedence, timers, conditional options, then encoding and packet size. The scope has to be internally consistent: pool inside the subnet, exclusions carved out before reservations, router inside the usable range, and every option a client actually consumes present exactly once.

Scope math. Subnet 10.20.30.0/24, pool 10.20.30.50–10.20.30.200, gateway 10.20.30.1, infrastructure statically held in .2–.49. A reservation for an address inside the dynamic pool is a race the server loses; reserve only from the excluded range.

Option precedence, where most reviews fail. Option 3 (router) and option 121 (classless static routes, RFC 3442) both carry routes. RFC 3442 says a client receiving option 121 MUST ignore option 3. So if you push 121 for a couple of /16s and lean on 3 for the default route, 3442-compliant clients lose their default route. Either put the default route (width 0) inside 121 or don't send 121. Encoding: width byte, that many significant destination octets, then 4 bytes of next hop; default route is width 0 followed by the gateway.

Timers. Option 51 lease, 58 T1 renewal, 59 T2 rebind. Defaults: T1 = 0.5×lease, T2 = 0.875×lease. ISC dhcpd default-lease-time 43200 (12 h), max-lease-time 86400 (24 h); Windows Server defaults to 8 days. At T1 the client unicasts DHCPREQUEST to the leasing server; at T2 it broadcasts to any server; at expiry it must stop using the address. If T1 ≥ T2 or T2 ≥ lease, clients renew too late or never rebind: set both explicitly when you shorten leases for a guest VLAN.

Conditional options. Option 60 (vendor class identifier) and option 77 (user class) let one scope serve phones and laptops. Keep the classes disjoint; overlapping conditions yield nondeterministic option sets. Option 43 is opaque: the vendor's encoding is the contract.

Encoding and size. Option 119 (domain search, RFC 3397) is DNS wire format with compression pointers; a hand-built string breaks it, and Windows historically ignored 119, taking the suffix from option 15. Option 26 sets interface MTU: a value above the link MTU black-holes large packets. Replies must fit the client's 576-byte minimum reassembly buffer (RFC 2131); big option sets overflow into sname/file via option 52 overload, and some clients drop oversized replies.

optionmeaningdefault / note
3routerignored if 121 present (RFC 3442)
51lease43200 s (ISC), 8 d (Windows)
58 / 59T1 / T20.5× / 0.875× lease
119domain searchRFC 3397 wire format
121classless routesoverrides 3

Lease trace (lease 3600 s). T1 = 1800, T2 = 3150. t=1800: unicast REQUEST to the leasing server; on no ACK, retry. t=3150: broadcast REQUEST to any server. t=3600: lease expires, client stops using the address and restarts DISCOVER. Detection: server logs a REQUEST with no matching lease, or the client shows 169.254.x.x.

Failure modes and detection. Wrong 121 → no default route; ip route shows no default, local subnet still reachable. Reservation inside the pool → duplicate address; ARP-conflict or duplicate-IP alerts. Misordered T1/T2 → rebind storm at T2; visible as a broadcast spike in server logs. Malformed 119 → missing search domains; resolvectl status or scutil --dns. Oversized reply → client never ACKs and falls to APIPA; tcpdump shows the reply leaving the server.

Trade-offs and rollback. Long leases (8 d) cut server load but slow reclamation; short leases (1 h) suit guest/hotspot. For endpoints that ignore options, config management (cloud-init, MDM) or RA is the alternative. Keep the prior scope in version control; dhcpd -t validates syntax before systemctl reload isc-dhcp-server, which re-reads config without dropping leases. On Windows, netsh dhcp server export first.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-15

Use reservations safely for infrastructure devices.

Answer

Core answer (say this first, ~90 seconds)

A DHCP reservation is an address-assignment convenience, not an identity control. It keys on something the client supplies, a MAC address or a DHCP client identifier (option 61), and anything on the segment can copy or spoof that. So use reservations to keep infrastructure addresses stable and documented, and treat network access as a separate problem solved by 802.1X or certificates.

Assumptions: ISC dhcpd or Windows Server DHCP; managed switches with DHCP snooping; "infrastructure" means switches, APs, cameras, printers, BMCs.

Three decisions make a reservation safe:

  • Identifier semantics. ISC dhcpd keys the lease on option 61 when the client sends it, falling back to the hardware address otherwise. A host stanza that names only hardware ethernet can therefore fail to match a client that sends option 61: check what your client actually sends. Windows Server DHCP reservations key on the MAC (chaddr) only.
  • Pool overlap. A reserved address inside the dynamic range can be handed to someone else. Exclude it explicitly.
  • Asset binding. The reservation should name the asset and owner, not just an address, or it rots.

Config that shows the mechanism

ISC dhcpd: reserved address outside the pool, keyed on option 61:

subnet 10.20.30.0 netmask 255.255.255.0 {
  range 10.20.30.100 10.20.30.200;   # dynamic pool
  option routers 10.20.30.1;
}

host sw-floor3 {
  client-identifier 01:aa:bb:cc:dd:ee:ff;  # 01 = Ethernet hw type, then MAC
  fixed-address 10.20.30.10;               # outside the range above
  option host-name "sw-floor3";
}

Cisco IOS equivalent: ip dhcp excluded-address 10.20.30.10 then a pool with host 10.20.30.10 255.255.255.0 and client-identifier 01aabb.ccdd.eeff. ISC also has infinite-is-reserved on; to give reserved leases no expiry.

Alternatives, and when reservations are wrong

ApproachGood forBreaks when
DHCP reservationMany devices, central record, one serverClient randomizes MAC/identifier; server down
Static IP on deviceDevices that must boot before DHCPConfig drift, no central inventory
Short lease + DNSClients that moveInfra needs a fixed address for mgmt

Reservations are the wrong tool when the device must be reachable before any DHCP server is up (use static), or when you actually want identity (use 802.1X).

Failure modes and how you catch them

  • MAC randomization. iOS 14+ and Android 10+ default to a randomized MAC on new networks; Windows 10/11 can enable random hardware addresses. The reservation silently stops matching. Detect: device gets a pool address, not its reserved one.
  • Replacement hardware (RMA). New NIC, new MAC, stale reservation. Detect: two records for one asset.
  • Duplicate identifier. Cloned VM or imaged device sends the same option 61. Detect: two leases, one identifier.
  • Network move. Reservation is bound to a subnet; the device lands elsewhere. Detect: no matching subnet.
  • Server failover. In an ISC failover pair or Windows split scope, the reservation must exist on both. Detect: address changes only after failover.
  • Decommission/reuse. Address recycled to a new device while the old record persists. Detect: asset record points at a live but wrong device.

Access control is separate. 802.1X with EAP-TLS client certs ties access to a key the device holds. MAB (MAC Authentication Bypass) is a fallback for devices that can't do 802.1X, but it authenticates a spoofable MAC: treat it as convenience, not security. DHCP snooping bindings (MAC, IP, VLAN, port, lease) feed Dynamic ARP Inspection and IP Source Guard, but only within the switch's trust model: trusted ports face the DHCP server, untrusted ports face clients, and the binding is only as good as the snooping that built it.

Test before you trust it: identifier change and spoof, replacement hardware, duplicate client, network move, server failover, and decommission/reuse.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-17

Capacity-plan and respond to DHCP pool exhaustion.

Answer

What I'd say first

Clarify two things before touching anything: is it one scope or all of them, and is the symptom "no offer" (clients time out) or "wrong offer" (NAK or conflict)? Those point at different causes. I'll assume a single flat /24 scope, 253 usable addresses, mixed wired and wireless clients, and clients failing to get an offer at peak.

Exhaustion is a rate problem, not a count problem. In steady state the number of addresses you need is arrival rate × lease duration (Little's law). A /24 with 253 usable addresses and 8-hour leases supports roughly 253/8 ≈ 31 new clients per hour. A floor that onboards 200 devices an hour at shift change exhausts it in about an hour and a half, however many addresses you think you "have".

Diagnose with the lease-state breakdown

Pull the lease database and count by state. Each state points somewhere different:

StateWhat it meansWhat it points to
freeavailable now—
activein use, unexpiredreal demand
expired / releasedreclaimableshould return to free
declinedclient found a conflict (DHCPDECLINE)duplicate or rogue source
abandonedserver-side conflictinvestigate, then reclaim
reservedexcluded from the dynamic poolstale-reservation audit

If free is near zero but expired+released is large, reclamation is broken, not capacity. If declined is climbing, you have a duplicate-address source: a demand bug, not a capacity bug.

Worked check

Scope 10.20.30.0/24, 253 usable, 8h lease, peak 200 new clients/hour.

  • Required concurrent leases = 200 × 8 = 1600.
  • Available = 253. Deficit = 1347.
  • Drop the lease to 1h: 200 × 1 = 200, which fits in 253 with ~20% headroom.
  • Or keep 8h and expand: you need ≥1600 addresses, so /21 (2046 usable). /23 (510) and /22 (1022) both still fall short.

That is the decision: lease duration is the cheap lever, subnet size the expensive one, and the arithmetic says which one actually closes the gap.

Trade-offs

  • Shorten the lease: cheapest, immediate. Cost is more renewals (clients renew at T1, half the lease, by default), more server and relay load, and a client that can't reach the server at renewal loses its address. Wrong when the server or relay path is unreliable.
  • Expand the subnet: more addresses, but a bigger broadcast domain, a re-IP, and firewall/ACL churn. Wrong when the real problem is churn you haven't fixed.
  • Segment (a scope per floor, SSID or VLAN): contains blast radius and lets you size each pool to its own demand. Wrong when clients roam and you'd fragment a pool that should be shared.

Failure modes to name

  • Decline storm: a duplicate source triggers mass DHCPDECLINE; addresses sit in probation and the pool drains though nothing is really in use. Detect: declined count spiking in the lease DB.
  • Failover split: two peers each serve half the pool, so effective capacity is half what the scope says. Detect: compare per-peer free counts.
  • Stale reservations: excluded addresses nobody uses. Detect: reserved count against actual MAC activity.
  • Rogue DHCP: a second server hands out addresses from the same range. Detect: clients holding addresses outside your scope, or duplicate-address reports.

Response order

  1. Confirm which scope and read the state breakdown.
  2. If reclamation is broken, fix it: expired and released should return to free.
  3. If churn or declines are the cause, fix the source before adding capacity.
  4. If it's genuine growth, shorten the lease first, measure, then expand or segment.
  5. Never reclaim active leases by hand: you'll cause duplicate allocations. Test the change against a peak event, a failover, and a decline storm before rolling it out.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-13

Design resilient DHCP relay service.

Answer

Assumptions first. IPv4 DHCPv4, clients on routed subnets, one relay per client subnet (the L3 gateway or a switch with ip helper-address), servers centralized in a management VRF. If the relay sits in a different VRF from the clients, the answer changes and I'll say how.

Core answer. The relay's whole job is to be the only thing that knows which subnet the client is on, because the client has no address yet. It does that by stamping giaddr with the address of the interface it received the broadcast on, then unicasting to the server. The server picks the pool from giaddr: that is the mechanism, and it's why giaddr must be an address in the client's subnet, not the relay's loopback or management address. Get giaddr wrong and the server hands out an address from the wrong pool, and the client is unreachable.

Trace of one DISCOVER:

client 0.0.0.0:68 -> 255.255.255.255:67  DISCOVER, giaddr=0.0.0.0
relay  (ingress Gi0/1, addr 10.20.1.1) sets giaddr=10.20.1.1,
       inserts option 82 sub-1 circuit-id="Gi0/1:vlan20", sub-2 remote-id=relay-id,
       unicasts 10.20.1.1:67 -> 10.0.0.10:67
server selects pool 10.20.1.0/24 from giaddr, OFFER -> 10.20.1.1:67
relay broadcasts OFFER to 255.255.255.255:68 on Gi0/1

Option 82 is the trust boundary. The relay inserts circuit-id (sub-option 1) and remote-id (sub-option 2); the server can then scope a pool or options to a port. A client must never be allowed to supply its own option 82: otherwise it picks its own pool. On Cisco, DHCP snooping drops option 82 arriving on untrusted ports by default; ip dhcp snooping information option allow-untrusted is what re-enables it, so leave it off. On the server side, only trust option 82 from relay addresses you've enumerated.

When giaddr can't be in the client subnet (relay in a different VRF, or an unnumbered client interface) use RFC 3527 link-selection (option 82 sub-option 5) to carry the client subnet and let giaddr be an address the server can route back to. RFC 5107 (sub-option 11) forces renewals through the relay instead of direct to the server, which matters if you're doing per-port accounting.

HA: two helpers is not HA. RFC 2131 has the relay forward to every configured server and the client take the first offer. Two independent servers means two lease databases and duplicate-address risk. The deciding question is whether the servers share lease state:

optionlease statedeciding criterion
two ip helper-address entries, independent serverssplitonly if pools are disjoint per relay
ISC/Kea failover pair, both listedshareddefault choice; one peer down, other serves
anycast VIP in front of a pairsharedneeds the LB to be stateless per transaction

Failure modes and detection. One-way path (forward works, reply dropped by ACL or uRPF): relay counters show forwarded >> replies received. Duplicate relay on one segment: server lease table shows two leases for one MAC with different remote-ids. VRF leak: server logs "no free leases" or the relay shows zero replies because giaddr isn't reachable from the server VRF. Oversized options: RFC 2131 requires clients to accept at least 576 bytes; a long circuit-id plus vendor options can push past that and old clients drop the OFFER silently. Client renewal: T1 fires at 50% of lease, T2 at 87.5%, and the client retransmits with a 4s ±1s initial interval doubling to a 64s cap, if renewals are unicast straight to the server and the relay isn't in the path, per-port option 82 scoping breaks at first renewal.

Rate limiting. DHCP is UDP with a spoofable source. ip dhcp snooping limit rate 15 on access ports caps DISCOVER floods. On the relay's uplink, permit UDP/67 only to the enumerated server addresses: an open relay forwards to whatever a spoofed packet names.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-14

Design and test DHCP lease lifecycle and failover.

Answer

Assumptions I'd state first. DHCPv4, two servers running ISC dhcpd (or Kea), one /24 with 254 usable addresses, ~250 concurrent clients, and a requirement to survive a single server loss for 30 minutes without handing out duplicate addresses. If this is DHCPv6 the timers and failover story differ, so I'd confirm that before going further.

Core answer. A lease moves through INIT → SELECTING → REQUESTING → BOUND, then RENEWING at T1 and REBINDING at T2. RFC 2131 sets T1 = 0.5 × lease and T2 = 0.875 × lease unless the server overrides them. At T1 the client unicasts a DHCPREQUEST to the server that granted the lease; at T2 it broadcasts, and any server may extend it. If nothing answers by lease expiry the client must stop using the address and go back to DISCOVER. Every failover decision hangs off those three timers.

EventTimerOn an 8 h leaseClient action
T10.5 × lease4 hunicast REQUEST to the granting server
T20.875 × lease7 hbroadcast REQUEST, any server may answer
expirylease8 hstop using the address, send DISCOVER

Timer choice. Lease length trades reclamation against renewal load. Renewal rate is roughly N/lease, so 250 clients on an 8 h lease generate ~0.009 renewals/s; on a 1 h guest lease, ~0.07/s. ISC dhcpd ships default-lease-time 43200 s (12 h) and max-lease-time 86400 s (24 h); I'd shorten for mobile/Wi-Fi and lengthen for stable wired clients.

Failover. ISC dhcpd implements the DHCP failover protocol over TCP 647, exchanging BNDUPD/BNDACK binding updates. Two modes: load balance (split 128, i.e. 50/50: each server owns half the pool and holds the other half as backup) and hot standby (one primary, one standby). The key parameter is MCLT (Maximum Client Lead Time), default 3600 s: it bounds how far one server may extend a lease beyond what its partner knows. When a server loses its partner it goes communications-interrupted, then partner-down after max-response-delay (default 60 s), and must wait MCLT before reusing the partner's free leases.

Trade-offs. Load balance uses both servers and doubles throughput, but both are allocating, so a partition risks duplicates. Hot standby keeps one server idle but is simpler to reason about and gives a clean takeover. Kea's HA hook library offers load-balancing, hot-standby and passive-backup, and can use a third backup node as a witness to break ties: worth it if you can't tolerate split brain. Windows DHCP failover uses the same MCLT concept, default 1 h.

Failure modes. Split brain: a partition where both servers go partner-down and both allocate from the same free pool → duplicate addresses. Detect via DHCPDECLINE, ARP conflicts, client "address in use". Bound it by keeping MCLT ≥ expected partition duration and adding a witness. Clock jump: lease expiry is wall-clock, so a forward jump expires live leases and a backward jump keeps dead ones; run NTP and alert on step changes. Pool exhaustion: no OFFER, clients fall back to APIPA (169.254/16).

Test plan. Validate config (dhcpd -t, kea-dhcp4 -t), capture with tcpdump -n port 67 or 68 or 647. Then: kill the partner before T1 (client renews normally), between T1 and T2 (survivor must answer), after T2 (broadcast rebind). Partition the link and confirm both sides' state transitions and that no duplicate is handed out. Suspend a client past expiry and confirm it DISCOVERs. Move a client to a new subnet and confirm the NAK. Restore after split brain by reconciling lease files and diffing for duplicates before re-enabling.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-24

Recover DHCP after database corruption or split brain.

Answer

Recovering DHCP after database corruption or split brain

Assumptions I'd state first: this is a two-node DHCP HA pair, ISC DHCP failover or Kea's HA hook library, and the failure is either a corrupted lease database on one node or a split brain where both nodes believed the partner was down and allocated independently. The invariant that governs everything: at most one allocator may hand out a given address at a time. Recovery is quiesce → establish a consistent epoch → reconcile → resume with one authority.

Why leases conflict

In ISC DHCP failover, the secondary is only allowed to allocate an address the primary has already leased, or one whose potential-expiry has passed. The window that gates this is MCLT (Maximum Client Lead Time), default 3600 s (mclt in dhcpd.conf). When the pair loses communication, each node sits in communications-interrupted; after MCLT elapses with no contact, a node may declare partner-down and take over the partner's half of the pool. If both do that, both allocate from the same free addresses and you get duplicates. The arbiter on reconnect is the last-transaction-time / epoch each node recorded: the node with the later consistent epoch wins, and the other's conflicting bindings are resolved.

Kea's HA library has the same shape: modes hot-standby, load-balancing, passive-backup; in load-balancing each server owns a fraction of the pool. Kea trips into partner-down when heartbeats fail past max-response-delay (default 10000 ms) and it has more than max-unacked-clients (default 5) outstanding.

The recovery, in order

  1. Quiesce. Stop the DHCP service on both nodes (or firewall the failover port, 647/udp for ISC). No allocation while you reconcile. This is the step that stops the bleeding.
  2. Preserve evidence. Copy dhcpd.leases / the Kea memfile or SQL lease table, plus logs, before touching anything. You need the epoch to arbitrate.
  3. Pick the authoritative epoch. Compare last-transaction-time on both nodes. The later one is the base; the earlier node's post-split allocations are suspect.
  4. Reconcile. Merge the two lease sets. For each address, keep the binding with the later expiry; mark addresses that appear in both with different client-ids as conflicted and quarantine them (ISC: set binding state abandoned; Kea: exclude from the pool).
  5. Resume one authority. Either bring up a single node and let the partner resync via the failover protocol's recover → recover-wait → normal sequence, or restore HA and let resolve-conflict run.

Trade-offs

OptionCostWhen
Single authority, partner resyncsLonger degraded window; one node carries all loadCorrupted DB, or you can't trust the epoch comparison
Restore HA, let resolve-conflict runFaster, but re-imports possibly-bad bindingsBoth DBs intact, only the split is the problem

Quarantine is the cheap insurance: a quarantined /24 costs you capacity but guarantees no duplicate. Expand it back gradually once you've watched a full lease cycle (default-lease-time, e.g. 7200 s) with no conflicts.

Failure modes and how you detect them

  • Duplicate IPs: clients log ARP conflicts or DAD failures; dhcpd logs abandoned leases. Detect by scanning the reconciled set for the same address bound to two client-ids.
  • NAK storms: a client renewing a lease the new authority doesn't know gets a NAK and restarts DORA. Watch NAK rate; a spike means your reconciliation dropped bindings.
  • Sleeping clients: a laptop that slept through the split renews an old lease; if you quarantined its address it gets NAKed. Expected, but budget for the churn.
  • Re-split, if the failover link is still flaky, you split again. Fix the link before re-enabling HA.

Worked trace: ISC failover restart

Node B restarts with a stale DB. It enters recover, sends BNDUPD for every binding to A; A replies BNDACK or BNDNAK. B moves to recover-wait, then normal once A acks. If A is unreachable, B sits in communications-interrupted; only after MCLT (3600 s) may it go partner-down. That 3600 s is exactly the window in which a duplicate can be created if A also went partner-down, which is why you quiesce both before reconciling rather than trusting the timer.

The one-line answer: stop both allocators, keep the later epoch, quarantine every address bound to two clients, then bring back a single authority and let the partner resync. Never let two nodes allocate from the same free pool while you reconcile.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-23

Design DHCP observability and alerting.

Answer

Assumptions first. A Kea or ISC dhcpd pair in failover, ~20k clients across 40 subnets, relays stamping option 82, DHCP snooping on the access switches. On a single server with no relays, drop the relay and HA planes and keep the rest.

The core answer: three planes, and only one of them is metrics.

Plane one is server-side counters, because the server is the only component that knows the truth about leases. From Kea's control channel, or ISC's OMAPI plus the lease file, export per subnet: pool utilization, cumulative assignments, NAK count, Decline count, and Discovers that never got an Offer. Stop at subnet granularity: 40 series, not 20,000.

Plane two is relay and switch telemetry. Every forwarded packet carries option 82 (RFC 3046) with circuit-id and remote-id, which is what turns "a client can't get an address" into "port Gi1/0/14 on sw-3". DHCP snooping adds dropped and rate-limited packets, and offers seen on untrusted ports.

Plane three is packet capture, and here the usual "sampling saves money" instinct is wrong for DHCP. Do the arithmetic: 20k clients on an 8-hour lease renew at T1 = 4h, six times a day, plus one DORA at join. That's about 320k packets a day; at ~400 bytes with relay headers, ~130 MB. Thirty days of full capture is under 4 GB. Capture everything. The real cost is decode CPU and PII, MAC addresses and hostnames are personal data in the EU, so the trade-off is retention and access control, not bandwidth. Sample only if you're capturing at a relay aggregating hundreds of subnets.

What actually fires.

SignalThresholdWhat it means
Pool utilizationwarn 85%, page 95%Exhaustion is silent: clients get no Offer and no NAK
NAK rate>1% of Requests over 5 minScope mismatch, or a client that moved
Decline rate>0.1% of ACKsDuplicate address detection firing: rogue static IPs
DORA p95>1 s on-LAN, >3 s relayedRelay or server saturation
Two Offers, one xid, different server-idanyRogue DHCP server
Snooping drops on an untrusted portanyMisconfigured client or attack
Failover heartbeat gap>60 s, or MCLT (3600 s default) exceededSplit-brain risk
Clock skew between peers>1 sLease binding updates go wrong

Failure modes and how you catch them. Silent pool exhaustion is the one that bites: no NAK, no error, just clients timing out. You catch it by counting Discovers with no matching Offer within 2 s, keyed on xid plus client MAC. Rogue servers you catch by the server-id mismatch above, or by snooping. A relay that strips option 82 or drops giaddr produces NAKs with a "wrong network" reason and no circuit-id: a relay config bug, not a client one. Split-brain in failover shows up as two peers claiming the same lease; the clock-skew alert is your early warning.

One trace. A laptop moves from VLAN 30 (10.30.0.0/24) to VLAN 40 (10.40.0.0/24) with a live lease. It broadcasts a Request for 10.30.0.57 naming the old server-id. The VLAN 40 relay stamps giaddr 10.40.0.1 and option 82. The server sees giaddr inside 10.40.0.0/24 but a requested address outside it, so it sends NAK. The client falls back to Discover and gets a 10.40.0.x address. A NAK burst right after a subnet move is correct behaviour; the same burst with no moves is a config error.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-19

Design IPv6 SLAAC and DHCPv6 configuration.

Answer

Assumptions: dual-stack enterprise LAN, one /64 carved from a /48, modern clients (Windows 10+, macOS, Linux, iOS/Android), one or two routers on the segment. If you need per-host address audit or you have embedded devices, the answer shifts.

Core answer. RA is not optional: it is the only mechanism that hands a host a default route and tells it which prefixes are on-link. DHCPv6 cannot supply a default route. So RA is always on, and the real decision is where addresses come from.

Default design: SLAAC for addresses, RDNSS in the RA for DNS, DHCPv6 off. Set A=1 and L=1 on the /64, M=0, O=0. Stateless, no server, survives a server outage. Move to stateful DHCPv6 (M=1, A=0) only when you need address tracking for audit/ACLs, addresses bound to a DUID, or options SLAAC cannot carry. Use DHCPv6 for options only (M=0, O=1) when you want SLAAC addresses but centralized DNS and search domains.

Mechanism. The RA (ICMPv6 type 134, source = router link-local, destination ff02::1) carries: the M and O bits in the flags field; a Prefix Information Option per /64 with A (autonomous. Usable for SLAAC), L (on-link), valid and preferred lifetimes; a Router Lifetime (default 1800 s) that is the default-route hold time; and, per RFC 8106, RDNSS and DNSSL options. Defaults: MaxRtrAdvInterval 600 s, MinRtrAdvInterval 200 s, valid lifetime 2592000 s, preferred 604800 s.

A subtlety that decides the design: M=1 tells hosts to get addresses from DHCPv6, but the A flag is what actually drives SLAAC on most stacks. Windows and Linux still form a SLAAC address if A=1 regardless of M. To force DHCPv6-only you must set A=0 and M=1. And Android has historically shipped no stateful DHCPv6 client, so M=1/A=0 leaves Android devices with no address at all.

SLAAC vs stateful DHCPv6

SLAACStateful DHCPv6
Server needednoyes
Address trackingnoyes, by DUID
Default routefrom RAstill from RA
Androidworksno client
RenumberRA lifetimesserver + RA

Config (radvd, checked against radvd 2.19):

interface eth0 {
    AdvSendAdvert on;
    MinRtrAdvInterval 200;
    MaxRtrAdvInterval 600;
    AdvDefaultLifetime 1800;
    AdvLinkMTU 1500;
    AdvManagedFlag off;
    AdvOtherConfigFlag off;
    prefix 2001:db8:1:1::/64 {
        AdvOnLink on;
        AdvAutonomous on;
        AdvValidLifetime 2592000;
        AdvPreferredLifetime 604800;
    };
    RDNSS 2001:db8:1:1::53 { AdvRDNSSLifetime 600; };
};

DAD trace. Host forms tentative 2001:db8:1:1::a1b2 (IID via RFC 7217 stable, or RFC 4941 temporary). It joins ff02::1:ff00:a1b2 and sends an NS with source ::, target = tentative address. It waits DupAddrDetectTransmits (default 1) × RetransTimer (1000 ms) = 1 s. No NA arrives, so the address becomes preferred. An NA means duplicate: the address is dropped.

Failure modes and detection.

  • Rogue RA advertising a bogus prefix or default route: blackholes traffic. Detect with RA Guard on the access switch and by logging RAs from non-router MACs.
  • Rogue DHCPv6 handing out wrong DNS: detect with DHCPv6 snooping and by logging server DUIDs.
  • Multicast loss: RAs go to ff02::1; misconfigured MLD snooping drops them and hosts lose the default route after the 1800 s Router Lifetime. Symptom is connectivity dying at ~30 min; check MLD snooping.
  • Renumber: let the old prefix's valid lifetime run down before withdrawing it, or in-flight connections break.
  • Router down: hosts drop the default route after Router Lifetime (1800 s), not immediately.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-20

Diagnose intermittent IPv6 duplicate-address failures.

Answer

"Intermittent" is the clue. DAD only runs when an address is generated (boot, interface up, link change, or address lifetime expiry) so a duplicate only bites when two nodes run DAD inside the same window, or when the NS/NA never reaches the other node. I'd assume Linux hosts, SLAAC, same L2 segment, and start by capturing the DAD exchange to see who answers the NS for the tentative address.

DAD is defined in RFC 4862 (SLAAC) and RFC 4861 (Neighbor Discovery). A node with a tentative address joins the solicited-node multicast group FF02::1:FF00:0/104, the last 24 bits of the address, sends DupAddrDetectTransmits Neighbor Solicitations, default 1, from the unspecified source :: to that group, and waits RetransTimer, default 1000 ms. Any Neighbor Advertisement for the target inside that window means the address is a duplicate: DAD fails, the address goes to dadfailed, and it is not used.

First artefact, the capture:

tcpdump -i eth0 -n -vv 'icmp6 and (ip6[40] == 135 or ip6[40] == 136)'

A duplicate looks like this:

15:04:22.101 IP6 :: > ff02::1:ff4e:66a1: ICMP6, neighbor solicitation, who has fe80::a00:27ff:fe4e:66a1, length 32
15:04:22.102 IP6 fe80::a00:27ff:fe4e:66a2 > ff02::1: ICMP6, neighbor advertisement, tgt is fe80::a00:27ff:fe4e:66a1, length 32

The NS source is :: (that is DAD, not normal ND) and the NA goes to ff02::1 because the NS source was unspecified. The NA's source MAC is the other owner; that is the thread to pull.

Second artefact, causes with mechanism and detection:

CauseWhy it breaksDetectFix
Cloned VM image, shared MACSame EUI-64 IID → same SLAAC addressip -6 addr shows the same address on two hosts; MACs matchRegenerate MAC per clone; RFC 7217 stable privacy with a per-host secret
Simultaneous clone bootBoth nodes are tentative, so neither answers the other's NS (RFC 4861 §7.2.4) → both pass DADip -6 neigh resolves the address to two MACs; ND table flapsStagger boot; per-host RFC 7217 secret
Host + bridged VMHost and VM share the L2 link and IIDNA arrives from the host's own MACDistinct MAC; NAT instead of bridge
MLD snooping, no querierSwitch drops the solicited-node multicast → NS never reaches the other node → DAD false passDAD passes but traffic collides; no NS on the peer's captureEnable MLD querier or disable snooping on the access port (RFC 4541)
Privacy address rotation (RFC 4941)Temporary address regenerates and collides transientlyuse_tempaddr=2, address changesNot a real duplicate; widen or accept
AnycastShared by design; RFC 4862 §5.4 excludes anycast from DADN/ANot a duplicate; don't expect DAD to flag it

The simultaneous-clone row explains "intermittent" best: DAD cannot catch two nodes that are both tentative at the same time, because neither is allowed to answer. You only see it when both boot within the same second.

Trade-offs. Disabling DAD, net.ipv6.conf.<if>.dad_transmits=0 or accept_dad=0, removes the ~1 s delay and the false failures, but it also removes detection of real duplicates: you trade a loud failure for a silent one. Optimistic DAD (RFC 4429, accept_dad=2) lets the address be used before DAD finishes, cutting boot delay but opening a brief window where a duplicate is in use. Raising dad_transmits from 1 to 3 catches a slow responder but triples the wait to ~3 s per address. Fix identity generation first; touch DAD knobs only on a specific interface, never globally.

Failure modes to name. MLD snooping without a querier is the nastiest: DAD passes, the duplicate is live, and the symptom is intermittent connectivity, not a DAD log line. A bridge loop reflects an NA from the node's own other interface, so the node sees itself as a duplicate: compare the NA source MAC against the local MACs. A cloned image with a shared stable_secret produces the same RFC 7217 address on every clone, which looks like a duplicate but is a provisioning bug.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-21

Integrate DHCP leases with dynamic DNS securely.

Answer

Core. Run the update from the DHCP server, not the client, unless every client already has a per-machine Kerberos identity. Give the server one TSIG key, scope it with a BIND update-policy grant to the dynamic subdomain and to the A and DHCID types only, and write a DHCID record (RFC 4701) beside every A. Make every delete conditional on the DHCID matching, so a delete can never remove a record a newer lease already owns. Set the record TTL to the lease time. The rest is failure handling.

Assumptions: BIND 9 authoritative, ISC DHCP 4.4 or Kea as the updater, RFC 2136 updates authenticated with TSIG (RFC 8945), forward and reverse zones both dynamic, clients not AD-joined.

Who owns the update.

client-ownedserver-owned
key holderevery clientDHCP server only
identityper-client (GSS-TSIG, RFC 3645) or one shared keyone TSIG key
wins whenclients are managed and AD-joinedclients are unmanaged, embedded, or you can't push config
failureone leaked client key writes anywhere in its grantserver is a single writer; a failover pair must coordinate
auditupdates arrive from many sourcesone source, one log

Client-owned is only defensible with per-client identity: GSS-TSIG in an AD domain, where each machine authenticates with its own Kerberos principal. With a shared key handed to clients, one compromised laptop rewrites the zone. Server-owned (ignore client-updates in ISC DHCP) keeps the key on one host and needs no client credentials; the cost is that the server must learn the client's name from DHCP option 81 (RFC 4702) or ddns-hostname.

Config. BIND side:

key "ddns-key" { algorithm hmac-sha256; secret "..."; };
zone "dhcp.example.com" {
  type primary;
  update-policy { grant "ddns-key" subdomain "dhcp.example.com." A DHCID; };
};

update-policy replaces allow-update; the grant is the least privilege: this key can touch A and DHCID under one subdomain and nothing else. ISC DHCP side:

ddns-update-style interim;
ddns-updates on;
ignore client-updates;
ddns-domainname "dhcp.example.com.";
ddns-ttl 3600;                      # match the lease time
key "ddns-key" { algorithm hmac-sha256; secret "..."; };
zone dhcp.example.com. { primary 10.0.0.53; key "ddns-key"; }
zone 0.0.10.in-addr.arpa. { primary 10.0.0.53; key "ddns-key"; }

Kea's D2 does the same job with tsig-keys, forward-ddns/reverse-ddns, and ddns-use-conflict-resolution on.

What actually goes on the wire. Client requests host1.dhcp.example.com with option 81, S flag set (server should update). Server ACKs, then sends one RFC 2136 UPDATE:

  1. Add: prerequisite DHCID RRset does not exist for host1; add A 10.0.0.17 TTL 3600 and DHCID <hash>. If another lease already owns the name, the prerequisite fails and the update is rejected: no silent overwrite.
  2. Renew: prerequisite DHCID matches <hash>; replace the A.
  3. Expiry or release: prerequisite DHCID matches <hash>; delete A and DHCID. If the client renewed first and the DHCID changed, the prerequisite fails, the delete is a no-op, and the live record survives. That is the race-safe cleanup, and it is one line of prerequisite, not a policy document.

Failure modes.

  • Stale record after expiry. The delete failed: key rotated, server down, zone transfer lag. The name now points at an IP leased to someone else. Detect by diffing the zone against the lease file nightly, or checking each A's DHCID against active leases. Cost: traffic for a trusted hostname reaches a different machine, which is a data-leak path, not a 404.
  • Delete-after-renew. Without the DHCID prerequisite, an expiry sweep at T deletes a record the client refreshed at T−1s; the host is unresolvable until the next renew. Detect: intermittent NXDOMAIN for hosts that are demonstrably up, correlated with update log lines.
  • Key compromise. One key covers the whole dynamic subdomain. Detect: BIND update logging plus a source-IP check. Alert on updates from outside the DHCP server's address. Cost: the holder can point any name in the grant at any address.
  • Failover pair. Two peers updating one zone without coordination produce duplicate DHCID RRs and last-writer-wins A records; reverse lookups flap. ISC DHCP failover coordinates DDNS between peers: use it, or run one updater.
  • TTL longer than the lease. The record outlives the lease and resolvers keep serving it after the IP is reassigned. Detect by comparing zone TTL to lease time; fix by setting ddns-ttl to the lease.

Curated: · Written: · Reviewed:

Difficulty: Hard