Architecture and the log model
This page describes what the code does, including the parts that are less flattering. If the code contradicts a claim on this page, the page or the code has a bug. Please report it.
The query
Section titled “The query”-
Your device sends a query to an opdns address. Anycast routing delivers it to the nearest PoP (point of presence, an opdns server location).
-
On the PoP,
opdns-edgefirst compares the client address with the source block list. It refuses a blocked source without any more work. Then it identifies the profile and the device from the transport (Identification).Some sources ask for a profile but do not encode a valid one. Examples are a malformed DoT or DoQ server name and a reserved IPv6 address. Other sources name a profile that does not exist. The edge answers both as if they named no profile: the public path, unfiltered and not logged. The edge refuses a query for a suspended profile at this point. Then it evaluates the policy of the profile (Policy order).
-
The edge itself answers a blocked or rewritten name. It also answers the reserved check name (
check.opdns.ioand random names below it), after identification and before policy. The answer to the check name describes what the edge saw: PoP, profile, identification, transport, and device name. The edge never forwards or logs this name. It never counts it as profile traffic or charges it to rate limits. -
The edge forwards an allowed name to Unbound, on the same machine over loopback. Unbound does the recursion, the caching and the DNSSEC validation.
-
The edge applies two more tests to the answer (CNAME uncloaking, rebinding protection), writes one log record, and replies. Over UDP, it first fits the answer to twice the size of the question (four times for an identified query). To do this, it removes records that a resolver answer does not need. If that is not enough, it truncates the answer, so that the client tries again over TCP. This does not apply if the client proved its address with a DNS cookie. The edge also rate-limits responses for each client network (Limits).
What Unbound sees
Section titled “What Unbound sees”Unbound sees only allowed queries, and only from the edge on loopback. It never sees the profile, the device name, or a query that the policy blocked. It holds no per-profile configuration. Everyone on that PoP shares its cache.
Unbound does not see the client address either, with one exception by design. If EDNS Client Subnet (ECS) is on, the edge passes a part of the client address to Unbound. Unbound then forwards it to authoritative servers. In the Anonymized mode, the default for new profiles, the edge passes a prefix (/24 for IPv4, /56 for IPv6). In the Full mode, it passes the full address.
Every opdns PoP runs with client subnet forwarding on. For a profile with
ECS off, a query then carries a /0 opt-out. This opt-out tells
authoritative servers not to use the client address.
Every PoP runs the same Unbound release (1.26.2 today). We build it from the NLnet Labs source after we make sure that its checksum is correct. We do not take it from a distribution. The image build fails if the binary reports a different version.
Unbound keeps a local copy of the root zone (RFC 8806). It transfers the zone from the published sources of the root servers. It accepts a copy only when the ZONEMD digest of the copy is correct. Then it answers its own iterator from that copy. So a cold lookup (a lookup with nothing in the cache) sends nothing to the root servers. Clients cannot query that copy directly.
If the copy is missing or expired, Unbound asks the root servers as any resolver does. Cold lookups are then slower, but there is no outage. Self-hosted nodes keep the same copy from the same sources, on by default. Their owner can point it to a different source or turn it off (Local root zone).
Where each privacy switch applies
Section titled “Where each privacy switch applies”The edge makes one record for each identified query. The
privacy policy, section 4
lists the fields. The three privacy switches act on the PoP, before the
record exists outside the machine. Retention and destination act at ingest,
after the record crossed the internal logs stream. Ingest is the step in
the control plane (the central services behind the dashboard and the API)
that receives and stores records.
| Switch | Applied | What leaves the PoP |
|---|---|---|
| Logs off | PoP | no record, only an hourly count of the profile’s queries by outcome |
| Client IP off | PoP | the record without the client address |
| Domain logging off | PoP (and again at ingest) | the record without the name, the answer addresses or the rule text. The list name, device, outcome and timing stay. |
| Retention | ingest | n/a. It sets the expiry of each stored row. |
| Destination | ingest | the record, whatever the destination |
While an organization is over the monthly query quota of its plan, the PoP treats its profiles as if logs were off. It sends hourly counts and no records until the month resets.
Records wait in a ring buffer on each PoP. If the control plane is unreachable, they wait in a disk spool, capped at 1 GiB. When the spool is full, the oldest records are dropped first. Logging is never on the critical path of the query.
What ingest adds
Section titled “What ingest adds”For the rows that it stores in the cloud database, ingest adds three columns after the privacy switches apply. It uses a GeoIP country database (the free country database of DB-IP) and classification data built into the control plane. The Attributions page credits them. The three columns are:
- The country of each answer address.
- The company that the query reached (Google, Apple, Meta, Amazon, Microsoft, or the CDNs Cloudflare, Akamai, Fastly), from its name or its answer addresses.
- The country of the client, only when the profile logs client IP addresses. If that switch is off, the client address never reaches ingest, and ingest does not look up a country for it.
If domain logging is off, there are no names or answer addresses. So there are no answer countries and no company either. The lookups run on the control plane’s own servers. No address goes to a third party. Records queued for your node get none of these columns.
Destination by destination
Section titled “Destination by destination”This table shows what the cloud does and keeps for queries that your devices send to the cloud addresses:
| Destination | Cloud resolves the query | Record crosses logs |
Stored in ClickHouse | Queued for your node | Counters |
|---|---|---|---|---|---|
cloud |
yes | yes | yes, until retention | no | yes |
self-hosted |
yes | yes | no | yes, until your node acknowledges it, 24 hours max | yes |
both |
yes | yes | yes | yes | yes |
none |
yes | yes | no | no | yes |
| logs off | yes | no | no | no | yes, from the PoP’s hourly counts |
This has three results, and we hide none of them:
-
If you choose your node as the destination, the cloud still sees the queries that you send to cloud addresses. The cloud resolves each of these queries. Its record passes through the
logsstream and a per-profile queue on its way to your node. The cloud database does not store it. -
A query sent to your own node never touches the cloud. The node writes its record to its SQLite file, and the record stays there.
-
Dashboard views of the logs on your node go through the cloud. When you open Logs or Analytics, the request goes to your node over its link. The result comes back through the servers of opdns, readable in transit (TLS protects each hop). opdns does not store it.
The node has no GeoIP data. So for the destinations view, the control plane adds the country of each answer address on the way. While the live tail is open, the cloud asks the node for new rows every second (the stream) or every 2 seconds (the polling fallback of the dashboard).
Ingest also keeps counters: hourly totals for each profile by outcome, with no names and no addresses, for 400 days. Ingest makes them from every record, whatever its destination. It also makes them from the hourly counts that the PoPs send for two cases: profiles with logs off, and queries blocked by a CSAM operator entry, which are never logged. Analytics reads its totals and timeline from these counters when only the time range is filtered, whatever the destination.
For this reason, the overview works with logs off and for the none and
self-hosted destinations. Any other filter needs per-query rows and
follows the destination: relayed to the node, or empty for none. The
cloud does not count a query sent directly to your node.
Where data lives
Section titled “Where data lives”| Store | What | Retention |
|---|---|---|
| PoP memory | the query while it is answered. Rate-limit buckets (per client address, and per client network, name and type for response rate limiting). | seconds. Buckets until idle. |
| PoP memory | a check’s facts (PoP, profile id, identification, transport, ECS, device name) under its random name, readable over HTTPS by anyone who has the name | 60 seconds |
| PoP disk spool | records while the control plane is unreachable | until delivered, 1 GiB cap |
logs stream |
records after the switches on the PoP, before the switches at ingest | 24 hours max |
| ClickHouse | records for cloud and both |
your retention (1 to 90 days) |
| ClickHouse hourly rollups | per profile and hour: counts by status, domain, device, answer network, company and answer country, summarized from the stored records | expire with the records that they summarize |
| ClickHouse aggregates | hourly counts per profile, no names or addresses | 400 days |
nodelogs queue |
records for your node | until acknowledged. At most the node queue setting of the profile (24 hours by default, or 12 hours, 1 hour or not queued), and 1 GiB fleet-wide. |
| Your node’s SQLite | your node’s own records and the deliveries from the queue | the profile’s retention |
The control plane runs in Canada. The points of presence are servers in several countries. The privacy policy, section 6 lists the regions and sub-processors.
Lists and profiles on the PoP
Section titled “Lists and profiles on the PoP”Lists reach the PoPs as one signed, memory-mapped file: the list artifact.
This file contains every blocked name one time, with the set of lists that
contain it. Format version 2 gives each name two sets: the lists that match
the name itself, and the lists that match names below it. So a list can
hold suffix rules (example.com: the name and everything below), exact
rules (=example.com) and children-only rules (*.example.com). The
policy engine looks up the query name in the first set, and each of its
parents in the second set. Artifacts of format 1 (suffix rules only) still
load.
Before opdns publishes a build, it tests the build against a never-block guard list. This list includes opdns’s own names, the DNS root, the TLD infrastructure and similar names. The build must also pass four gates: how much each list changed, the memory budget, the guard again, and popular sites that are newly blocked. If a build fails, opdns does not publish it, and the PoPs keep the previous build. A build that passes goes to a few canary PoPs first. It reaches the rest of the fleet only if the block and failure rates of these PoPs stay in line with the other PoPs.
The operators can roll the fleet back to an earlier build. Each build also keeps a private record of the source line that produced each entry. opdns uses this record to answer “why is this blocked?” The record is a separate file, not part of the artifact that the PoPs and nodes load.
Profiles reach the PoPs as whole documents on an internal stream, one for each profile. The newest version wins. When a PoP starts, it reads the newest snapshot and then follows the stream. Each message and snapshot is signed with Ed25519. A PoP that has the public keys refuses a message or snapshot that is unsigned or badly signed, and keeps what it had. The index that points at the newest snapshot is not signed, and the PoP trusts its own saved state as it is.
Every minute, the control plane rewrites a reserved system profile, and every PoP reports when it applied it. This measures the time from when a change is saved to when it is in force on each PoP. The target is under 2 seconds.
The self-hosted link
Section titled “The self-hosted link”An enrolled node keeps one outbound WebSocket to link.opdns.net,
authenticated by its node token. These messages go over it:
- The cloud sends profile changed and lists changed notices, log batches for the profile, and dashboard queries. After a profile changed notice, the node fetches the profile, which is signed. The node makes sure that the signature matches the keys that it learned at enrollment or that you pinned. Lists changed names the version that the fleet serves, never a build that is still in its canary. After a rollback, it names an older version, and the node installs it (List updates and rollbacks).
- The node sends acknowledgements, query results, and periodic health. At
most
link.max_inflight_queriesdashboard queries run at once (4 by default). If a query finds no free slot within a second, the node answers it at once with no rows and marks it partial (overload). The health report contains versions (node, Unbound, profile, lists, log schema), uptime, last sync, SQLite size and oldest record time, pending and dropped record counts, clock offset, whether Unbound is healthy, and the round-trip time of the link. - The node rotates its token. It asks for a new token every 90 days (or
when you run
opdns-node rotate-token), stores it, and confirms it. The old token stops working 10 minutes later.
The node accepts no inbound connections from opdns. If the link is down,
the node keeps resolving. The cloud marks the node offline when the link
closes. If the link server that holds the link stops, the cloud marks the
node offline within about 30 seconds. After 10 minutes offline, the owners
of the account get an email, unless they turned the alert off.
opdns-node unenrol revokes the node’s token in the cloud before it
deletes the token locally.
On your network, the node itself answers your local names and the reverse
lookups of private addresses. Local names are in home.arpa by default,
and come from its hosts setting and your DHCP leases. These queries never
reach Unbound, the internet or opdns, unless you set your router as the
place to forward unknown names to
(Local names).
The node answers only private, CGNAT, link-local, ULA and loopback sources, plus the sources that you allow. So if the internet can reach the node, it is still not an open resolver (a resolver that answers anyone) (Network access). For more information, see Logs on your node and Offline behavior.
Suspended profiles
Section titled “Suspended profiles”An operator can suspend a profile, for example for abuse. The profile stays
identified. But on every PoP and enrolled node, opdns refuses each of its
queries (its addresses, linked IPs and devices). The answer is REFUSED
with Extended DNS Error 15 (Blocked) and the text profile suspended. The
public explanation of the operator follows, when there is one. opdns never
forwards the query, and the edge writes no log record and no counter for
it, as on the public path.
opdns refuses the changes of the customer until the profile is reinstated. The internal note of the operator travels with the profile to the PoPs, which ignore it. opdns removes the note from every copy that a customer receives: the profile API, the node’s document, and the data export (Suspended profiles).
The public path
Section titled “The public path”opdns resolves a query that identifies no profile without filtering, with
no per-query record and with counters only, under per-source rate limits.
Examples are plain IPv4 DNS from an address that is not linked, or DoH to
/dns-query. See The public resolver path.
Operator blocks
Section titled “Operator blocks”A small operator-level list, for legal orders and abuse, applies before any profile rule. It applies on the PoPs, for every profile and on the public path. opdns answers its blocks with NXDOMAIN, whatever the block mode of the profile. The answer has Extended DNS Error 15 (Blocked), never 17, so you can tell these blocks apart from your own filtering.
The extra text is a reason code (legal_order, abuse, csam) and,
except for CSAM, a public reference. Some entries apply only in one
country. opdns never logs a query blocked by a CSAM entry. It only counts
it.
A second list blocks client address prefixes that abuse the service. opdns refuses plain DNS and DoT queries from them with EDE 18 and closes their DoH, DoH3 and DoQ connections. This happens before identification and without a log record.
Each of the two files is announced with its version and SHA-256. A PoP refuses a file if its content does not match the announcement, or if it is older than the announcement. The PoP then keeps its current rules. A PoP still accepts a file that is newer than the last announcement, or that was never announced. So polling alone keeps working.
Self-hosted nodes receive neither list. To learn what qualifies for an operator block and how to appeal one, see Operator blocks. Policies links to the policy and the transparency reports.