# nlnetlabs/unbound architecture

> Architecture diagram of the GitHub repository nlnetlabs/unbound, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nlnetlabs/unbound
- Repository: https://github.com/nlnetlabs/unbound

## Overview

Unbound is a validating, recursive, caching DNS resolver. A client query enters the daemon’s listening and worker system, is processed as a mesh query through recursive iteration and DNSSEC validation, and is answered using cached or locally authoritative data before a response is sent. The graph also preserves documented code-level capabilities visible in the source index, including DNS64, client-subnet handling, response-IP policy, DNSCrypt, dnstap, and cachedb. Some runtime wiring is not shown in the excerpts, so those links are dashed and unverified.

Main entry points: [`daemon/worker.c`](https://github.com/nlnetlabs/unbound/blob/master/daemon/worker.c) (Daemon worker), [`services/cache/dns.c`](https://github.com/nlnetlabs/unbound/blob/master/services/cache/dns.c) (DNS caches), [`iterator/iterator.c`](https://github.com/nlnetlabs/unbound/blob/master/iterator/iterator.c) (Recursive iterator), [`services/mesh.h`](https://github.com/nlnetlabs/unbound/blob/master/services/mesh.h) (Query mesh)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Resolver runtime"]
  node_listener["DNS listener<br/>[listen_dnsport.c]"]
  node_worker["Daemon worker<br/>[worker.c]"]
  node_events["Network events<br/>[netevent.c]"]
  node_config["Resolver configuration<br/>[config_file.c]"]
end

subgraph group_resolution["Query resolution"]
  node_mesh["Query mesh<br/>[mesh.h]"]
  node_iterator["Recursive iterator<br/>[iterator.c]"]
  node_validator["DNSSEC validator<br/>[validator.c]"]
end

subgraph group_data["DNS data"]
  node_cache[("DNS caches<br/>[dns.c]")]
  node_authzone[("Local authoritative zones<br/>[authzone.c]")]
  node_localzone[("Local zones<br/>[localzone.c]")]
  node_cachedb[("Cachedb backend<br/>[cachedb.c]")]
end

subgraph group_extensions["Resolver extensions"]
  node_dns64["DNS64 synthesis<br/>[dns64.c]"]
  node_subnet["EDNS client subnet<br/>[subnetmod.c]"]
  node_respip["Response IP policy<br/>[respip.c]"]
  node_dnscrypt["DNSCrypt<br/>[dnscrypt.c]"]
  node_dnstap["Query telemetry<br/>[dtstream.c]"]
end

subgraph group_api["Client interfaces"]
  node_libapi["libunbound API<br/>[libworker.c]"]
end

node_client(("DNS client"))
node_response(("DNS response"))

node_client -.->|"sends query"| node_listener
node_listener -.->|"dispatches query"| node_worker
node_worker -->|"uses networking"| node_events
node_worker -->|"reads settings"| node_config
node_worker -.->|"starts query"| node_mesh
node_mesh -.->|"activates module"| node_iterator
node_iterator -->|"looks up records"| node_cache
node_iterator -.->|"requests validation"| node_validator
node_validator -->|"uses cached data"| node_cache
node_authzone -->|"uses DNS cache"| node_cache
node_worker -.->|"uses zone service"| node_authzone
node_worker -.->|"uses local zones"| node_localzone
node_cachedb -->|"integrates cache"| node_cache
node_worker -.->|"enables synthesis"| node_dns64
node_worker -.->|"enables subnet module"| node_subnet
node_worker -.->|"enables response policy"| node_respip
node_events -->|"supports DNSCrypt"| node_dnscrypt
node_worker -.->|"records query events"| node_dnstap
node_libapi -->|"submits query"| node_mesh
node_worker -.->|"sends answer"| node_response

click node_listener "https://github.com/nlnetlabs/unbound/blob/master/services/listen_dnsport.c"
click node_worker "https://github.com/nlnetlabs/unbound/blob/master/daemon/worker.c"
click node_events "https://github.com/nlnetlabs/unbound/blob/master/util/netevent.c"
click node_config "https://github.com/nlnetlabs/unbound/blob/master/util/config_file.c"
click node_mesh "https://github.com/nlnetlabs/unbound/blob/master/services/mesh.h"
click node_iterator "https://github.com/nlnetlabs/unbound/blob/master/iterator/iterator.c"
click node_validator "https://github.com/nlnetlabs/unbound/blob/master/validator/validator.c"
click node_cache "https://github.com/nlnetlabs/unbound/blob/master/services/cache/dns.c"
click node_authzone "https://github.com/nlnetlabs/unbound/blob/master/services/authzone.c"
click node_localzone "https://github.com/nlnetlabs/unbound/blob/master/services/localzone.c"
click node_cachedb "https://github.com/nlnetlabs/unbound/blob/master/cachedb/cachedb.c"
click node_dns64 "https://github.com/nlnetlabs/unbound/blob/master/dns64/dns64.c"
click node_subnet "https://github.com/nlnetlabs/unbound/blob/master/edns-subnet/subnetmod.c"
click node_respip "https://github.com/nlnetlabs/unbound/blob/master/respip/respip.c"
click node_dnscrypt "https://github.com/nlnetlabs/unbound/blob/master/dnscrypt/dnscrypt.c"
click node_dnstap "https://github.com/nlnetlabs/unbound/blob/master/dnstap/dtstream.c"
click node_libapi "https://github.com/nlnetlabs/unbound/blob/master/libunbound/libworker.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_listener,node_worker,node_events,node_config,node_client toneBlue
class node_mesh,node_iterator,node_validator toneAmber
class node_cache,node_authzone,node_localzone,node_cachedb toneMint
class node_dns64,node_subnet,node_respip,node_dnscrypt,node_dnstap toneRose
class node_libapi,node_response toneIndigo
```

## Components

### Resolver runtime

- [DNS listener](https://github.com/nlnetlabs/unbound/blob/master/services/listen_dnsport.c): `services/listen_dnsport.c`
- [Daemon worker](https://github.com/nlnetlabs/unbound/blob/master/daemon/worker.c): `daemon/worker.c`
- [Network events](https://github.com/nlnetlabs/unbound/blob/master/util/netevent.c): `util/netevent.c`
- [Resolver configuration](https://github.com/nlnetlabs/unbound/blob/master/util/config_file.c): `util/config_file.c`

### Query resolution

- [Query mesh](https://github.com/nlnetlabs/unbound/blob/master/services/mesh.h): `services/mesh.h`
- [Recursive iterator](https://github.com/nlnetlabs/unbound/blob/master/iterator/iterator.c): `iterator/iterator.c`
- [DNSSEC validator](https://github.com/nlnetlabs/unbound/blob/master/validator/validator.c): `validator/validator.c`

### DNS data

- [DNS caches](https://github.com/nlnetlabs/unbound/blob/master/services/cache/dns.c): `services/cache/dns.c`
- [Local authoritative zones](https://github.com/nlnetlabs/unbound/blob/master/services/authzone.c): `services/authzone.c`
- [Local zones](https://github.com/nlnetlabs/unbound/blob/master/services/localzone.c): `services/localzone.c`
- [Cachedb backend](https://github.com/nlnetlabs/unbound/blob/master/cachedb/cachedb.c): `cachedb/cachedb.c`

### Resolver extensions

- [DNS64 synthesis](https://github.com/nlnetlabs/unbound/blob/master/dns64/dns64.c): `dns64/dns64.c`
- [EDNS client subnet](https://github.com/nlnetlabs/unbound/blob/master/edns-subnet/subnetmod.c): `edns-subnet/subnetmod.c`
- [Response IP policy](https://github.com/nlnetlabs/unbound/blob/master/respip/respip.c): `respip/respip.c`
- [DNSCrypt](https://github.com/nlnetlabs/unbound/blob/master/dnscrypt/dnscrypt.c): `dnscrypt/dnscrypt.c`
- [Query telemetry](https://github.com/nlnetlabs/unbound/blob/master/dnstap/dtstream.c): `dnstap/dtstream.c`

### Client interfaces

- [libunbound API](https://github.com/nlnetlabs/unbound/blob/master/libunbound/libworker.c): `libunbound/libworker.c`

### Other components

- **DNS client**
- **DNS response**

## Connections

- DNS client → DNS listener: sends query (evidence: `README`)
- DNS listener → Daemon worker: dispatches query
- Daemon worker → Network events: uses networking (evidence: `daemon/worker.c`)
- Daemon worker → Resolver configuration: reads settings (evidence: `daemon/worker.c`)
- Daemon worker → Query mesh: starts query (evidence: `daemon/worker.c`)
- Query mesh → Recursive iterator: activates module
- Recursive iterator → DNS caches: looks up records (evidence: `iterator/iterator.c`)
- Recursive iterator → DNSSEC validator: requests validation
- DNSSEC validator → DNS caches: uses cached data (evidence: `validator/validator.c`)
- Local authoritative zones → DNS caches: uses DNS cache (evidence: `services/authzone.c`)
- Daemon worker → Local authoritative zones: uses zone service
- Daemon worker → Local zones: uses local zones
- Cachedb backend → DNS caches: integrates cache (evidence: `cachedb/cachedb.c`)
- Daemon worker → DNS64 synthesis: enables synthesis
- Daemon worker → EDNS client subnet: enables subnet module
- Daemon worker → Response IP policy: enables response policy
- Network events → DNSCrypt: supports DNSCrypt (evidence: `util/netevent.c`)
- Daemon worker → Query telemetry: records query events
- libunbound API → Query mesh: submits query (evidence: `libunbound/libworker.c`)
- Daemon worker → DNS response: sends answer
