DNS cookies
What is DNS cookies?
DNS cookies, defined in RFC 7873, are an optional EDNS0 extension letting a resolver and authoritative server exchange a token proving a UDP reply isn't spoofed, without the overhead of a full TCP handshake. AdminKit's router DNS-hijack guide covers this as one signal behind detecting a tampered resolver.
By AdminKit team, Netbase JSC · Updated
DNS cookies (RFC 7873, document record at the IETF Datatracker) are an optional EDNS0 extension, defined in RFC 6891 and registered as EDNS0 option code 10 in IANA’s DNS Parameters registry, that lets a DNS client and server exchange a pair of opaque tokens — a client cookie and a server cookie — attached to plain UDP queries and responses. Once a server has issued a client a server cookie, it can reject or deprioritize any later query claiming to be from that client but presenting the wrong cookie, giving lightweight protection against off-path attackers who spoof a query’s source address to poison a cache or trigger a reflected denial-of-service response, without the overhead of switching every query to TCP. Support is optional and not universal: a resolver or authoritative server that doesn’t implement DNS cookies simply ignores the extension and falls back to ordinary unauthenticated UDP behavior. On the server side it is a switch an operator turns on: Unbound’s answer-cookie option, off by default, makes it answer requests containing DNS Cookies as specified in RFC 7873 and RFC 9018. Knot DNS’s cookies module describes the same mechanism as lightweight protection against denial-of-service and amplification attacks, with the server generating its cookie from a secret value it keeps. See the EDNS0 entry for the extension mechanism DNS cookies and several other options, like ECS and Extended DNS Error, all attach to.
What DNS cookies protect against:
- Off-path attackers spoofing a query’s source address to poison a resolver’s cache.
- Reflected denial-of-service responses triggered by a forged query source.
- Both without the overhead of upgrading every query from UDP to a full TCP handshake.
AdminKit groups dNS cookies under its DNS cluster — browse the AdminKit glossary index for other related terms.
Frequently asked questions
What do DNS cookies actually protect against?
Off-path attackers who spoof a query's source address to poison a resolver's cache or trigger a reflected denial-of-service response -- a narrower defense against spoofing, not full transport security.
Do DNS cookies require switching queries from UDP to TCP?
No -- that's the point: a client and server exchange a client cookie and server cookie attached to plain UDP queries and responses, giving lightweight protection without the overhead of a full TCP handshake.
What happens if a resolver or server doesn't support DNS cookies?
Support is optional and not universal -- a resolver or authoritative server that doesn't implement DNS cookies simply ignores the extension and falls back to ordinary unauthenticated UDP behavior.
What extension mechanism do DNS cookies attach to?
EDNS0, defined in RFC 6891 -- the same extension mechanism that ECS and Extended DNS Error also attach their own options to.