DNS interview questions and answers
DNS interview questions check whether you understand how a name becomes an address and what breaks along the way: resolvers and authoritative servers, delegation, TTLs and caching, record types, DNSSEC and attacks on resolvers. Fundamentals are about the lookup path and the records. Experienced candidates get outage and migration scenarios, where the right answer names the cache, the TTL and the command that proves it.
By Evin JohnPublished 8 min read
Why interviewers spend time on DNS
Plenty of production outages trace back to a name that did not resolve, resolved to the old place, or resolved slowly. SRE, DevOps, platform and network roles therefore treat DNS as core knowledge, and security teams add attacks on it. Software engineers usually get one or two questions; infrastructure candidates can get a whole round with a live dig session or a migration plan to talk through.
- Lookup pathExplain, step by step, what happens between an application calling the resolver library and receiving an address. Interviewers interrupt to ask which component caches what.
- Records and zonesPick the right record for a job, read a zone snippet, spot what is wrong with it.
- Tool readingSome rounds show
digoutput and ask you to explain the flags, sections, TTLs and status code. - ScenarioAn outage or a cutover: users see the old site, one region fails, mail bounces, pods resolve slowly. You talk through evidence and fixes.
DNS fundamentals questions
| Question | What it tests | What a strong answer shows |
|---|---|---|
| What is the difference between a stub resolver, a recursive resolver and an authoritative server? | Roles | The stub lives in the OS and forwards the question. The recursive resolver does the legwork and caches. The authoritative server holds the zone and answers for it without asking anyone else. |
| What does delegation mean? | Hierarchy | A parent zone hands authority for a child to other name servers by publishing NS records for it. The root delegates com, com delegates example.com, and so on. |
| What is a fully qualified domain name, and why does the trailing dot matter? | Naming | An FQDN names a host all the way to the root, written with a final dot in zone files. Without it, many zone files and resolvers append a default origin or search domain. |
| Which record would you use to point a name to another name? | CNAME | A CNAME, as long as no other record sits at that name. Resolvers follow the alias and look up the target. |
| How does mail find its server? | MX | The sender looks up MX records for the recipient's domain and tries hosts in order of preference, lowest number first, then resolves each host to an address. |
| What is a PTR record? | Reverse DNS | It maps an address back to a name, under in-addr.arpa for IPv4 or ip6.arpa for IPv6. Mail servers often check that it exists and matches. |
| What are TXT records used for today? | TXT | Domain ownership checks for SaaS tools and certificates, and email policy: SPF lists who may send for the domain, DKIM publishes signing keys, and DMARC says what receivers should do with failures. |
| What does a CAA record do? | Certificates | It names which certificate authorities may issue certificates for the domain. Public CAs are expected to check it before issuing. |
| What does TTL mean on a record? | Caching | How many seconds a resolver may keep the answer. Higher means fewer queries and slower changes; lower means faster changes and more load on the authoritative servers. |
| What does the hosts file do relative to DNS? | Local overrides | On most systems the resolver library checks it before asking DNS, so a stale entry can override real answers for that machine only. It is a common cause of "works for everyone except me". |
| What is an SRV record? | Service discovery | It gives a host and port for a named service and protocol, with priority and weight. Some directory, voice and chat protocols use it instead of fixed ports. |
Intermediate: zones, caching and the protocol
| Question | What it tests | What a strong answer shows |
|---|---|---|
| What do the SOA fields control? | Zone timers | The primary server name, the admin contact, a serial number that secondaries compare, refresh, retry and expire timers for zone transfers, and a value used as the TTL for negative answers. |
| What is negative caching? | NXDOMAIN | Resolvers also cache the answer that a name does not exist, for a time taken from the SOA. Creating a record right after someone queried it can therefore look broken for a while. |
| NXDOMAIN versus NOERROR with no answer? | Status codes | NXDOMAIN means the name does not exist at all. NOERROR with an empty answer, often called NODATA, means the name exists but has no record of the requested type. |
| What are glue records, and when are they required? | Delegation | When a zone's name servers live inside that zone, such as ns1.example.com for example.com, the parent must also publish their addresses, or resolvers could never reach them. |
| Why can a parent and child disagree about NS records, and does it matter? | Lame delegation | The registrar publishes NS at the parent; the zone publishes its own. If they drift, some resolvers ask servers that no longer answer, which shows up as slow or failed lookups for some users only. |
| When does DNS use TCP? | Transport | When a UDP response is too large and comes back truncated, for zone transfers, and increasingly for encrypted transports. Blocking TCP 53 on a firewall breaks large answers, which matters more with DNSSEC. |
| What is EDNS? | Extensions | An extension that lets clients advertise a larger UDP buffer and carry extra flags, such as the DNSSEC OK bit. Overly large UDP answers risk fragmentation, so many resolvers keep the advertised size modest. |
| Why can't you put a CNAME at the zone apex, and what do providers offer instead? | Apex rules | The apex must hold SOA and NS, and a CNAME cannot share a name with other records. Providers offer alias or flattening records that resolve the target themselves and return addresses. |
| What is a wildcard record, and what does it not match? | Wildcards | *.example.com answers for names that do not otherwise exist. It does not cover names that exist with other types, and it does not reach deeper labels when an intermediate name exists. |
| How do zone transfers work, and why restrict them? | AXFR and IXFR | Secondaries pull the full zone (AXFR) or changes since a serial (IXFR) from the primary. Open transfers hand anyone a map of every internal name, so limit them to known secondaries and sign them. |
Some interviewers check that you know what is actually on the wire. A DNS message is a 12-byte header, then question, answer, authority and additional sections, with names written as length-prefixed labels and compressed by pointers.
import struct
def encode_name(name: str) -> bytes:
"""www.example.com -> 3www7example3com0 (length-prefixed labels)."""
out = b""
for label in name.rstrip(".").split("."):
out += bytes([len(label)]) + label.encode("ascii")
return out + b"\x00"
def build_query(qid: int, name: str, qtype: int = 1) -> bytes:
flags = 0x0100 # RD bit: ask the resolver to recurse
header = struct.pack("!HHHHHH", qid, flags, 1, 0, 0, 0)
return header + encode_name(name) + struct.pack("!HH", qtype, 1) # class IN
def read_name(msg: bytes, pos: int):
"""Follow compression pointers (top two bits set) back into the message."""
labels, jumped, end = [], False, pos
while True:
length = msg[pos]
if length & 0xC0 == 0xC0: # pointer: 14-bit offset from the start
if not jumped:
end = pos + 2
pos = struct.unpack("!H", msg[pos:pos + 2])[0] & 0x3FFF
jumped = True
elif length == 0:
return ".".join(labels), (end if jumped else pos + 1)
else:
labels.append(msg[pos + 1:pos + 1 + length].decode("ascii"))
pos += 1 + length
query = build_query(0x1A2B, "www.example.com")
print(query.hex())
# 1a2b0100000100000000000003777777076578616d706c6503636f6d0000010001
# A response: same id, QR and RA set, the question, then one A record whose
# name is a pointer (c00c) to offset 12, where the question's name starts
answer = b"\xc0\x0c" + struct.pack("!HHIH", 1, 1, 300, 4) + bytes([192, 0, 2, 44])
response = struct.pack("!HHHHHH", 0x1A2B, 0x8180, 1, 1, 0, 0) + query[12:] + answer
qid, flags, qd, an, _, _ = struct.unpack("!HHHHHH", response[:12])
name, pos = read_name(response, 12)
pos += 4 # skip QTYPE and QCLASS
rname, pos = read_name(response, pos)
rtype, rclass, ttl, rdlen = struct.unpack("!HHIH", response[pos:pos + 10])
ip = ".".join(str(b) for b in response[pos + 10:pos + 10 + rdlen])
print(hex(qid), flags & 0xF, an, rname, rtype, ttl, ip)
# 0x1a2b 0 1 www.example.com 1 300 192.0.2.44 (rcode 0 is NOERROR)dig www.example.com A # full answer with header flags and TTLs
dig +short example.com MX # just the MX targets and preferences
dig +trace www.example.com # walk the delegation from the root yourself
dig @ns1.example.com www.example.com +norecurse # ask the authoritative server directly
dig -x 192.0.2.44 # reverse lookup (PTR)
dig example.com DNSKEY +dnssec # keys and signatures for DNSSEC checks- In `dig` output, what do the `aa`, `rd` and `ra` flags mean?
aasays the answer came from an authoritative server,rdsays the client asked for recursion, andrasays the server offers it. A recursive resolver's cached answer will not carryaa. - Why does the TTL in repeated `dig` answers count down? You are seeing a cached copy in the resolver, which reports how many seconds remain. Querying the authoritative server shows the configured value.
- `+trace` and normal lookups disagree. Why?
+tracewalks the hierarchy fresh from your machine and skips your resolver's cache, so a difference usually means a stale cache, split-horizon views or a resolver that rewrites answers.
Senior questions: security and design
| Question | What it tests | What a strong answer shows |
|---|---|---|
| How does DNSSEC build trust? | Chain of trust | Each zone signs its records (RRSIG) with keys published as DNSKEY. The parent publishes a DS record, a hash of the child's key, and signs it, so a validating resolver can follow signatures from the root down. |
| What does DNSSEC not protect? | Limits | It proves authenticity and integrity, not secrecy: queries and answers are still visible. It also protects only zones that are signed and resolvers that validate. |
| How do NSEC and NSEC3 differ? | Denial of existence | Both prove a name does not exist. NSEC lists the next existing name, which lets anyone walk the zone. NSEC3 uses hashed names to make walking harder, though weak settings can still be cracked offline. |
| What is cache poisoning, and what defends against it? | Attacks | An attacker races the real answer with forged ones so the resolver caches a false record. Random transaction IDs and random source ports raise the guessing cost, and DNSSEC validation rejects forged data outright. |
| Why are open resolvers abused for amplification attacks? | Reflection | A small spoofed UDP query can trigger a much larger answer sent to the victim's address. Do not run open resolvers, apply response rate limiting on authoritative servers, and filter spoofed traffic at the network edge. |
| DNS over HTTPS versus DNS over TLS? | Encrypted DNS | Both encrypt the stub-to-resolver hop. DoT uses its own port, which networks can identify and block; DoH rides on HTTPS, which hides it among web traffic and can bypass corporate resolvers. Mention the policy trade-off for enterprises. |
| What is split-horizon DNS, and what goes wrong with it? | Views | The same name returns internal addresses inside the network and public ones outside. VPN users, encrypted DNS in browsers and forgotten records make the views disagree in confusing ways. |
| How does anycast help DNS? | Availability | Many servers announce the same address, and routing sends each query to a nearby one. It spreads load, cuts latency and absorbs attacks. The root servers and large providers rely on it. |
| What is a dangling CNAME and why is it dangerous? | Subdomain takeover | A record still points to a deleted cloud resource. If someone else can claim that resource name, they control content on your subdomain. Inventory records and remove them when the target is deleted. |
Scenario questions
- You moved the site to a new IP an hour ago. Some users still reach the old server. Why, and what now? Resolvers cached the old A record for its TTL, and some clients and runtimes cache longer than they should. Keep the old server serving or redirecting until the old TTL has passed everywhere, and next time lower the TTL a day or more before the move.
- Pods in Kubernetes make five DNS queries for every external call. Why? The default resolver config often sets
ndots:5with several search domains, so a name with fewer dots is tried with each suffix first. Use fully qualified names with a trailing dot, or tunendotsfor the workload. - Mail from your domain lands in spam after a provider change. Check the SPF record includes the new sender, DKIM keys are published for the new selector, and the DMARC policy is not rejecting aligned failures. Use the receiving side's headers to see which check failed.
- One region reports intermittent resolution failures. Compare answers from that region's resolvers against the authoritative servers, check for lame delegation, packet loss to one name server, or a firewall blocking TCP fallback for large responses.
- How would you move a domain to a new DNS provider without downtime? Recreate and compare every record, lower TTLs ahead of time, serve the zone from both providers, then change NS at the registrar. Keep the old provider live until the parent's NS TTL has passed, and plan DNSSEC key handover separately.
- An application ignores a DNS change for hours even though `dig` shows the new answer. The runtime or library is caching on its own, as some language runtimes and connection pools do. Check its DNS cache settings and whether long-lived connections simply never reconnect.
Fictional example
- Interviewer
- You created
portal.example.comten minutes ago. It resolves on your laptop, but a customer says it does not exist. What happened? - Candidate
- My guess is negative caching. If the customer's resolver asked for that name before I created it, it cached NXDOMAIN for the time the SOA allows. I would ask the authoritative servers directly with
+norecurseto confirm every one of them serves the new record, then check the negative TTL in the SOA. If both look right, the customer's resolver will pick it up when that negative entry expires. - Interviewer
- How would you avoid that next time?
- Candidate
- Create records before announcing or testing the name publicly, keep the negative caching value in the SOA reasonable, and add a check in the release runbook that queries each authoritative server. I would also confirm the customer is not using a resolver that rewrites failures into a search page.
A one-week DNS preparation plan
- Day 1: trace three domains with
dig +traceand explain each referral out loud. - Day 2: write a small zone from memory with SOA, NS, A, AAAA, CNAME, MX, TXT and CAA, then review every TTL choice.
- Day 3: caching. Explain positive and negative caching, and practice the IP-change and new-subdomain scenarios.
- Day 4: read the message format and parse one query and one answer by hand or in a short script.
- Day 5: DNSSEC. Draw the chain from root to your domain with DS, DNSKEY and RRSIG, plus what a validation failure looks like.
- Day 6: attacks and defenses: poisoning, amplification, dangling records and encrypted DNS policy.
- Day 7: a mock scenario round with a friend asking "how do you know?" after each claim.
For the transport underneath, read TCP/IP interview questions; for the broader networking survey, computer networks interview questions. DNS also comes up throughout DevOps engineer interview questions, where cutovers and service discovery are daily work.
Explaining a cache chain clearly is harder than it sounds once someone keeps asking "and which TTL?". Natively is an AI interview assistant for Mac and Windows that can transcribe a mock DNS round on your computer, so you can reread where your explanation jumped a step. In practice it can read a dig output or a zone file from a screenshot and suggest what to check next. With Pro or the free trial it can use the résumé and job description you add, and the transcript and notes stay available to review.
Questions people ask
What DNS questions are asked in interviews?
How a lookup works from stub to authoritative server, common record types, TTL and caching, negative caching, glue records, CNAME rules at the apex, when DNS uses TCP, DNSSEC, cache poisoning, and scenarios such as a slow IP change.
What is the difference between a recursive and an authoritative DNS server?
A recursive resolver finds answers for clients by following referrals and caches them. An authoritative server holds the zone and answers for its own names directly.
Why does a DNS change take time to appear?
Resolvers keep cached answers until the record's TTL runs out, and some applications cache on their own. Lower the TTL well before a planned change.
How should I prepare for DNS questions as a DevOps or SRE candidate?
Practice with dig, including +trace and direct queries to authoritative servers, learn the SOA timers and negative caching, and rehearse migration and outage scenarios out loud.
Where to go next
Practice with the same assistant you would use on a call: it listens, transcribes and suggests answers from your own resume and the job description.
Facts on this page were last checked on . Product details come from the Natively app itself; if something here is out of date, tell us at hello@heynatively.com.
