A UDP packet arrives at a DNS server claiming to come from an address the server has never met. There is no account, no certificate, no negotiated key, no handshake, and no memory of any prior conversation. The Internet's address book has never employed a bouncer; anyone can write any return address on the envelope.

DNS Cookies exist to hand that server one honest scrap of evidence: that somebody at the apparent address received an earlier reply and came back holding a token the server itself manufactured. That is the entire claim. It has survived a decade of operational wear precisely because nobody has been allowed to inflate it.

What RFC 7873 actually added: EDNS option code 10

RFC 7873, published in May 2016, put that evidence into EDNS option code 10. A client with no known Server Cookie attaches only an eight-byte Client Cookie. Once it has learned a Server Cookie, the option carries both. The original specification allowed a Server Cookie anywhere from eight to thirty-two bytes and left its private construction to the implementer — which meant a server needed no stored record per client. It could recalculate the token on the spot from the request address, the Client Cookie and a secret it already held.

That statelessness is the design's quiet genius. Nothing accumulates. Nothing needs garbage collection. The server keeps a secret and does arithmetic; the client keeps a pair of values and presents them.

BADCOOKIE is a door, not an error message

The state machine was built for partial deployment, because partial deployment is the only kind the Internet ever gets. A server that does not implement DNS Cookies ignores the option entirely. A supporting server that receives only a Client Cookie may, according to its own policy, drop the request, answer with BADCOOKIE, or simply process it — and when it responds, it hands over a Server Cookie so the client can climb into the stronger state. A malformed option yields FORMERR. An invalid or stale Server Cookie is treated as though it were absent.

BADCOOKIE therefore reads like an error and behaves like a doorway. A matching Client Cookie in the reply tells the client the response belongs to its exchange; the freshly returned Server Cookie supplies the value needed for a retry. If a brand-new value fails again immediately, the protocol points to TCP as a fallback — and repeated failures start to look less like an attack and more like an operational fault, such as members of an anycast service disagreeing about secrets or cookie construction.

A valid cookie lets a server relax the measures whose only job is defending against spoofed UDP source addresses. It does not switch off every abuse control the server owns, and treating it as a general trust badge is how bounded evidence gets overextended.

Why the token has two halves: NAT

Bind a Server Cookie to the public source address alone and one device behind a household gateway can mint a token that every other device sharing that address may use. Folding the Client Cookie into the server-side calculation separates those flows without forcing the server to remember anyone. The result is still not individual identity — the server sees the NAT's public address and nothing behind it — but it preserves the mechanism's narrow claim at the finest granularity the wire actually offers.

Anycast broke the private handshake, so RFC 9018 rebuilt it

Anycast created the harder historical problem. One service address can deliver consecutive packets to different machines, sometimes running different DNS software. RFC 7873 recommended shared server secrets but never standardised how implementations turned the inputs into a Server Cookie. Two vendors could hold the identical secret and still produce mutually unintelligible tokens. A client bounced from one node to another would appear to have brought a bad cookie while nothing malicious had happened at all.

RFC 9018, published in April 2021, converted that implementation freedom into an interoperable format. A version-1 Server Cookie is sixteen bytes: one byte of version, three reserved bytes, four bytes of timestamp and eight bytes of SipHash-2-4 output. With the eight-byte Client Cookie alongside it, the complete option is exactly twenty-four bytes. The hash covers the Client Cookie, the visible structural fields, the client IP address and the shared Server Secret — so the address shapes validation without ever being copied into the token itself.

The timestamp is a replay horizon, not a warranty

The timestamp gives the token an explicit expiry. RFC 9018 recommends accepting a value no more than one hour old, tolerating up to five minutes of future skew, and refreshing a cookie once it passes half an hour. These are standards recommendations, not proof that every deployment runs identical timers — but they establish the intent: the token is meant to die. An observer sitting on the path who captures it learns both the token and its usable window. The mechanism narrows replay; it does not abolish observation.

Secret rotation is where the protocol meets the pager

Interoperability turned secret rotation into an anycast coordination problem. The new secret must reach every node while all of them keep issuing under the old one and validating both. Only once distribution is complete do nodes begin issuing under the new secret, still honouring the old. The old value retires after clients have had time to refresh. Clock synchronisation joins secret consistency as part of the protocol's control surface, and a cryptographic primitive cannot rescue a fleet whose members disagree about the time or the rollout phase.

RFC 9018 also rewrote the Client Cookie guidance. Rather than demanding a hash over a client address that is often unknown at creation time, it recommends sixty-four bits of entropy per server IP. The client must stop reusing its cookie once its own address changes, because a stable token crossing networks quietly becomes a tracking handle. When a server is not known to support cookies, the client must not keep presenting the same failed identifier forever.

NAT leaves a residual limit that no RFC can legislate away: a host may never learn that its gateway's public address changed, and that public address stays visible to the server regardless.

What the cookie never claims

This is not identity. A household gateway, carrier-grade NAT or enterprise edge can put thousands of devices behind one public address. A compromised machine sitting at the correct address can still be abusive. An on-path observer can replay a visible cookie for as long as it lives. DNS Cookies neither encrypt a question nor authenticate the owner of a name, and they do not turn UDP into an accountable session.

What they do is raise the price of one specific lie — the off-path claim that a packet came from an address that never received the preceding traffic. That lie mattered because DNS could amplify it. A short question with a forged source address could induce a much larger response toward a victim; a forged request could make a recursive server burn work on lookups and DNSSEC validation; forged replies could race legitimate answers and try to poison a resolver's cache. DNSSEC authenticates data but enlarges messages and demands validation work. TSIG authenticates transactions but presupposes shared-key administration.

Source-port and transaction-ID entropy make blind guessing harder. Response-rate limiting constrains output. DNS Cookies slot in beside all of them as lightweight, stateless return-path evidence.

So the history of DNS Cookies is not the story of DNS acquiring identity. It is the story of evidence being fitted to the claim it can actually support. The first exchange proves almost nothing about intent; it creates a token that makes the next source-address claim expensive to forge from off path. RFC 7873 struck that bargain. RFC 9018 made it operable across a diverse anycast fleet — and in doing so exposed where the real authority sits: with client reuse policy, server response policy, synchronised time and the disciplined custody of shared secrets.

Ask a token to prove only the path it actually walked. Every stronger judgement belongs somewhere else.

Sources