DnsStream maintains persistent TCP connections to its configured forwarding targets and recovers automatically from network failures without requiring manual intervention. Event delivery during a failure depends on the configured recovery mode and available buffer capacity.
The term “event” is used in this document to mean any data being forwarded by DnsStream. Currently, events consist of DNS messages only.
A forwarding target is configured as a host and port in dnsstream.conf. The host may be an IPv4 address, an IPv6 address, or a DNS name. When a DNS name is used, DnsStream resolves it when a connection attempt is made. DnsStream cycles through the resolved addresses until one successfully connects.
forwarder ipv4 siem.corp.local 514
forwarder ipv6 siem-v6.corp.local 6514 tls=on tls-client-certificate=auto
Multiple forwarder directives may be present. Each target is resolved and managed independently.
DnsStream establishes connections to all configured forwarding targets. All successfully established connections are maintained in parallel and receive forwarded events in a load-balanced fashion. Slow forwarding targets wil process events from the forwarding queue more slowly and therefore will receive less events.
If one connection fails, DnsStream continues forwarding to the remaining active connections without interruption. Reconnection to the failed target runs independently in the background.
When reconnecting, DnsStream re-resolves the target hostname and attempts to establish a new connection using the available addresses.
Startup:
siem1.corp.local resolves to 10.0.2.10, 10.0.2.11, 10.0.2.12
attempt 10.0.2.10 → connected
10.0.2.11 and 10.0.2.12 not contacted
siem2.corp.local resolves to 10.0.3.10, 10.0.3.11, 10.0.3.12
attempt 10.0.3.10 → connected
10.0.3.11 and 10.0.3.12 not contacted
all events forwarded to 10.0.2.10 and 10.0.3.10
10.0.2.10 drops:
siem1.corp.local resolves to 10.0.2.10, 10.0.2.11, 10.0.2.12
attempt 10.0.2.10 → fails
attempt 10.0.2.11 → connected
forwarding resumes to 10.0.2.11
forwarding continues uninterrupted to 10.0.3.10
If all forwarding connections become unavailable, events accumulate in the in-memory ring buffer until a connection is restored.
The recovery option, configured on a forwarder directive, controls what happens to events that were in the process of being sent when a connection failure occurs.
Network errors are not always detected immediately. A write may appear to succeed at the TCP layer even though the data was not received by the collector, particularly if the connection fails between the write and acknowledgement.
The three recovery modes offer different trade-offs between potential event loss and duplicate delivery.
forwarder ipv4 192.168.68.100 1514 recovery=best-effort
For drop mode, events that were being sent at the moment of connection failure are discarded. DnsStream reconnects and resumes forwarding from new events only.
Send attempt
│
┌─────────▼──────────┐
│ Connection drops │ → events discarded
└────────────────────┘
DnsStream reconnects
Forwarding resumes from next event
Use when duplicate delivery is more disruptive than occasional event loss.
Not recommended for security telemetry where completeness matters.
Risk: Events in flight at the time of failure are lost, and events sent in the previous batch may also have been lost.
For best-effort mode, on reconnection, DnsStream resends the events that were in flight at the time of failure. This recovers events that may not have been received because the connection dropped during transmission.
Send attempt
│
┌─────────▼──────────┐
│ Connection drops │ → events returned to queue
└────────────────────┘
DnsStream reconnects
Retained events are resent
Forwarding resumes
This is the default behaviour when recovery is not configured.
It handles the common case where a failure is detected promptly and the in-flight events are considered undelivered.
Risk: If the collector received the events before the connection failure was detected, resending may produce duplicates. Events from an earlier batch may also have been lost if the failure was detected late.
In durable mode, on reconnection, DnsStream resends both the events that were in flight and the events sent in the previous batch.
This guards against situations where a network failure is not detected until a subsequent send attempt, meaning some apparently delivered events may not have reached the collector.
Previous sends Send attempt
│ │
┌─────────▼──────────────────────▼──────┐
│ Connection drops (detected late) │
└───────────────────────────────────────┘
│
▼
Previous and in-flight events
returned to queue
│
▼
DnsStream reconnects
Events are resent
Forwarding resumes
Recommended for deployments where event completeness is the priority and the receiving collector can tolerate or deduplicate occasional duplicate events.
Risk: Higher probability of duplicate delivery compared with best-effort. The receiving collector should be capable of handling duplicates, either natively or through deduplication rules.
| Mode | In-flight events on failure | Previously sent events | Duplicate risk |
|---|---|---|---|
drop |
Discarded | Not resent | None from retransmission |
best-effort |
Resent | Not resent | Low |
durable |
Resent | Resent | Moderate |
Default: best-effort (when the directive is not set).
These recovery modes provide different delivery guarantees at the transport level. They do not guarantee end-to-end, exactly-once delivery or prevent event loss if the forwarding queue reaches capacity.
DnsStream buffers events in its in-memory ring buffer whenever no forwarding connection is available.
The buffer decouples capture from forwarding. Events continue to arrive from the Windows ETW provider or Linux dnstap emitter independently of the forwarding connection state, subject to the available queue capacity.
Once a forwarding connection is re-established, the forwarding thread drains the buffer, delivering queued events as forwarding resumes.
When multiple forwarding targets are configured, DnsStream continues forwarding through any remaining active connections during a partial outage. The ring buffer is therefore primarily used when all forwarding connections are unavailable.
If the buffer fills completely before connectivity is restored, additional incoming events may be dropped. The eventsDropped counter in the queue metrics event reflects events lost due to queue capacity limits.
The buffer size is controlled by message-queue-size in dnsstream.conf.
See the Message queue section in the Configuration reference document for full details.
The ring buffer should be sized to accommodate the expected event volume during the longest anticipated period when all forwarding connections may be unavailable. Ideally multiple forwarders should be configured for redundancy, and to avoid events being dropped in the event of a forwarding target failure.
As a rough guide:
| Peak query rate | ~97 MB (default) | 256 MB | 512 MB |
|---|---|---|---|
| 10,000 qps | ~75 secs | ~195 secs | ~375 secs |
| 50,000 qps | ~15 secs | ~40 secs | ~75 secs |
| 150,000 qps | ~5 secs | ~13 secs | ~25 secs |
These are approximate figures. Actual capacity depends on average event size, which varies by DNS record type mix and output format.
With multiple forwarding targets configured, the effect of a connection failure depends on how many targets remain available.
| Connection state | Forwarding behaviour | Ring buffer |
|---|---|---|
| All targets connected | Events forwarded to all active targets | Not used for outage buffering |
| One or more targets disconnected | Forwarding continues to remaining active targets | Not used solely because of a partial outage |
| All targets disconnected | Forwarding pauses while reconnection is attempted | Incoming events buffered up to capacity |
| Connectivity restored | Forwarding resumes and queued events are drained | Buffered events delivered |
Multiple forwarding targets provide resilience against individual collector or network failures. For uninterrupted forwarding during a partial outage, configure at least two independent forwarding targets.
The message-queue-recovery directive is separate from the recovery option on the forwarder directive.
While recovery controls how in-flight events are handled following a connection failure during normal operation, message-queue-recovery controls what happens to buffered DNS messages across a service stop and restart.
message-queue-recovery on
message-queue-filename message.queue
| Value | Behaviour |
|---|---|
off |
In-memory events are discarded on service stop. No queue file is written. |
on |
On clean shutdown, buffered events are written to the queue file. On startup, the file is loaded and its events are forwarded, then the file is deleted. |
The queue file is written only during a clean shutdown.
Events buffered in memory at the time of a crash, forced termination, or power failure are not recoverable through this mechanism, regardless of the configured setting.
Queue persistence is available to all DnsStream users without requiring a licence or subscription.