A user in Lisbon opens a video site. The site’s DNS server sees the lookup coming from a recursive resolver elsewhere and points the user at a streaming server near that resolver. The DNS answer is valid. The video might still take a longer route than it needs to.
EDNS Client Subnet (ECS) lets a DNS resolver include an IP prefix representing the client’s network when it asks for an answer. The authoritative server can use that hint to pick a better content server. The price is that it learns something about the client that a conventional recursive lookup would have kept out of that query.
What is EDNS Client Subnet?
When your device asks the Domain Name System for an address, it typically sends the question to a recursive resolver. The resolver can answer from its cache. If it needs to look up the record, it sends its own queries, and the authoritative server for the domain normally sees the resolver’s outgoing IP address as the packet source.
ECS doesn’t change that source address. It adds a field to the DNS message that can say, for example, “The client is somewhere in this prefix.” It works with IPv4 and IPv6. The option travels in the OPT record provided by EDNS(0), the extension mechanism for DNS. RFC 7871 describes the ECS option and how to use it.
Think of a map inside a window envelope. The recipient sees a section of the map because someone chose to show it. A network prefix, though, describes a block of addresses; it doesn’t draw a boundary around a neighborhood.
Why would DNS want that hint?
A content delivery network may have several servers that can serve the same video. Its authoritative DNS can steer a viewer toward one of them by returning a particular IP address. If the resolver is a poor stand-in for the viewer’s network, an ECS prefix gives the CDN another signal for that decision. The CDN might know, for example, that traffic from that network reaches one of its sites through a better peering connection.
An anycast resolver can already receive queries at multiple locations under one IP address. That helps determine where the DNS query goes. ECS can influence which address the answer contains. These are two decisions, and the first doesn’t settle the second.
ECS doesn’t measure latency or guarantee the fastest server. Networks move, routes change, and the authoritative operator decides how much to trust the prefix. Some names have the same answer everywhere.
One query, two prefix lengths
Take a client whose address at the resolver is 192.0.2.37. Suppose the resolver sends 192.0.2.0/25 on a cache miss. The authoritative server answers with an IPv4 address for a content server and indicates that its answer works for the whole 192.0.2.0/24. The addresses below are reserved for documentation.
| Message | DNS question or answer | ECS source prefix | ECS scope length |
|---|---|---|---|
| Resolver → authoritative | Where is cdn.example.? (A record) | 192.0.2.0/25 | 0 in the query |
| Authoritative → resolver | A record: 203.0.113.10 | 192.0.2.0/25 (echoed) | 24 in the response |
The source prefix length says how many address bits the resolver supplied. The scope prefix length in the reply tells the resolver how broadly the answer applies. Here, the first 24 bits of the supplied address define the scope. The server learned a /25 and said the answer covers a larger block, the /24.
Now 192.0.2.180 asks the same resolver for the same record. It’s outside the original /25, which ends at .127. It’s inside the returned /24, so the resolver can reuse the cached answer while its TTL is valid and the response is otherwise a match. Had the server returned scope /25, that cache entry wouldn’t cover .180. The resolver would need another suitable cached answer or a new lookup.
This is the extra dimension ECS adds to DNS caching: TTL tells you when an answer expires; scope tells you which client networks it can serve. If an authority provides narrower scopes, fewer clients can share each cache entry. That can mean more entries and more upstream queries. A response scope of /0 says that the answer can be used for any client network, subject to ordinary cache rules.
If two resolvers return different addresses, don’t assume one is holding an old record. They may have asked from different networks or received deliberately different answers. The next step is to check how the domain steers traffic.
What does ECS reveal if DNS is encrypted?
A resolver that receives your query directly can already see the source IP for that connection. This might be your public address, a NAT gateway, or a VPN exit. ECS can pass on part of the address it associates with your query. RFC 7871’s privacy guidance recommends truncating to 24 bits for IPv4 and 56 for IPv6, and describes cases where sharing fewer bits is preferable. Those lengths are guidance, and the option can carry more bits.
The authoritative server can see both the DNS name and the supplied prefix. Even a truncated prefix can give it a clue about your ISP or network and help it correlate queries. ECS doesn’t alter the IP address used later to connect to the website.
With DNS over HTTPS (DoH), someone watching your connection to the resolver cannot read the DNS message on that hop. The resolver itself decrypts the request. It can still add ECS to its own queries. So the browser’s encrypted DNS setting and the resolver’s policy on sharing client prefixes answer different privacy questions.
That policy varies in practice. Google Public DNS documents how it detects ECS support at authoritative servers. Cloudflare’s 1.1.1.1 FAQ says it doesn’t generally send ECS, with a single exception for an Akamai debugging domain. If prefix disclosure matters to you, check the policy of the resolver your app actually uses.
How to see the option for yourself
If you operate an ECS-aware authoritative server in a lab, use BIND’s dig to ask it for the same record with and without a client prefix. Replace the example server and domain with your own. These commands ask the authority directly and use synthetic address data.
dig @198.51.100.53 cdn.example. A +norecurse +nosubnet
dig @198.51.100.53 cdn.example. A +norecurse +subnet=192.0.2.0/25
Compare the A records in the answer and look for CLIENT-SUBNET in the OPT section. If you see 192.0.2.0/25/24, read it as prefix, source length, and response scope. The two answers may contain the same IP: the server’s steering policy determines whether this particular input changes the result.
A direct test of the authority can’t tell you what a public or corporate resolver sends on your behalf. For that, inspect traffic leaving a resolver you operate or check incoming queries on an authoritative server you control. Use a fresh name in your test zone so a cache hit doesn’t prevent the upstream query you want to observe.
One last detail: dig +subnet=0 puts a source length of zero in the query. Under RFC 7871, that tells an ECS-aware resolver not to send any client-derived address bits upstream for that lookup. A scope length of zero in a reply says the answer can serve any network. Before interpreting a zero, check which field it’s in and which way the message is going.
