Skip to content

DNS Tunnels

A DNS tunnel carries data over DNS. The client encodes what it wants to send in the labels below a domain the attacker controls, and the attacker's authoritative server for that domain decodes it and encodes its answer in the reply. Because every query is a new name, nothing is cached and every packet reaches the attacker. DNS is allowed almost everywhere, which makes the tunnel a reliable channel for exfiltration and for command and control from a network that blocks everything else.

Some legitimate products use the same trick. Antivirus and endpoint agents look up file hashes over DNS, DNS blocklists encode addresses in names, and some CDNs and telemetry services put session data into labels. Their traffic looks like a tunnel because it is one. Exclusions exist for them.

You can find DNS tunnel findings on the Tunnels tab of the DNS page under Ethernet in the sidebar of your Nzyme web interface, next to the DNS Overview and Transaction Logs tabs. The Exclusions tab holds the domains and clients you have told Nzyme to ignore, and Settings has the detection parameters.

How Nzyme Detects DNS Tunnels

Nzyme's taps record every DNS query and reply. Nothing is computed on the tap. When the node stores a query, it computes the entropy of the part of the name below its registered domain (the eTLD+1, which the log already stores). For k7x2q9mz.data.example.com that is the entropy of k7x2q9mz.data. The registered domain itself is left out because it is the same for every query of a tunnel and would only dilute the signal.

Detection runs once a minute, per tenant, across all taps of the tenant. It looks at a window of detection window minutes that ends thirty seconds in the past, so that every tap has had the chance to report:

  1. Queries are grouped by client address and registered domain.
  2. A group is examined when the client looked up at least the minimum distinct names number of different names under the domain inside the window. A tunnel has to generate new names to get past caches, so a client that repeats the same few names is not a tunnel no matter what the names look like.
  3. The group becomes a finding when at least one of three indicators is present:
Indicator Present when
HIGH_ENTROPY The average entropy of the labels below the registered domain is at or above the entropy threshold.
LONG_NAMES The average length of the labels below the registered domain is at or above the name length threshold.
UNUSUAL_RECORD_TYPES The share of TXT, NULL, CNAME, MX, KEY and SRV queries is at or above the record type share threshold.

Each indicator points at a property a tunnel cannot avoid. Encoded data is random, so its entropy is high. Bandwidth over DNS comes from label length, so tunnels fill the labels to the limit. And the downstream channel needs record types that carry more than an address, so tunnels ask for TXT, NULL, CNAME or MX records where a normal client asks for A and AAAA.

Entropy alone is a weak detector, which is why it is one indicator of three and not the gate. Entropy is measured in bits per character. Hex encoding is capped at 4 bits, base32 at 5 and base64 at 6, while normal hostnames sit around 2.5 to 3.5. The gap is small, and short names never reach the cap. A tunnel that uses hex and short labels is caught by the distinct names gate and the record type indicator instead.

This replaces the entropy outlier detection that older taps ran on every packet. That detection compared each name to the average of the last ten minutes, so a tunnel that sent hundreds of random names per minute raised its own baseline and stopped standing out. It also measured the whole name, where a long legitimate parent domain scored as high as a short encoded label. Grouping by client and domain on the node, over the log that all taps feed, removes both problems.

A finding stays open and keeps counting while the client continues to query the domain inside the detection window. Once it has been quiet for longer than the window, new activity from the same client to the same domain becomes a new finding.

What a Finding Records

Field Meaning
Client The address that sent the queries, with the MAC address it was recorded with, if a tap recorded one. Behind a router that is the MAC address of the router, which is shown without asset.
Domain The registered domain the names were looked up under. Its authoritative servers are the other end of the tunnel.
Resolvers The DNS servers the queries were sent to.
Indicators Which of the three indicators were present.
Queries How many queries the client sent for names under the domain.
Distinct names How many different names it looked up.
Negative replies Replies with NXDOMAIN, SERVFAIL, REFUSED or another code that is not NOERROR. Tunnels that use NXDOMAIN as their downstream transport show a high share.
Average and maximum entropy Bits per character of the labels below the registered domain.
Average and maximum name length Characters below the registered domain.
Record types How many queries asked for each record type.
Names A sample of up to 100 full names that were looked up.
Taps The taps that observed the queries.

The finding page links to the DNS transaction log filtered to the client and the domain, which is the raw evidence.

Multiple Taps

Several taps often see the same query. Queries are merged by client, port and transaction, so a query seen by three taps counts once. The taps that observed the client are listed on the finding.

Working With DNS Tunnel Findings

The Tunnels tab lists the findings of the selected tenant that were active at any point in the selected time range, with the client, the domain, the indicators, the counts and when they were first and last seen. The Active DNS Tunnels chart shows how many findings were going on over time in the same range. The time range and the filters apply to the list and the chart alike. The list and its filters work like every other Ethernet search page, and the small filter icons next to values add that value to the filters. The short, copyable ID at the start of each row links to the finding's details page and is a stable link you can share. Findings that match an exclusion are marked as excluded and are no longer updated.

On the details page, the names and the record types tell you what kind of tunnel it is. Long base32 labels with TXT queries are a bulk data channel. Short hex labels with A queries and a high share of negative replies are a classic NXDOMAIN transport, where the attacker's server encodes its answer in whether the name exists. A few names with low entropy and ordinary record types are usually a product doing lookups, not a tunnel.

Before escalating, check who owns the domain. A security product, a DNS blocklist or a CDN behind it means an exclusion, not an incident. When the finding is real, isolate the client: everything it sent through the tunnel is with the attacker, and the domain's authoritative servers are the attacker's infrastructure.

Exclusions

An exclusion is a set of criteria: a domain and a client address or network. Every criterion that is set must match, and at least one must be set. The domain matches the finding's domain exactly or as a parent domain, so example.com matches findings for example.com and for sub.example.com. The client matches when the finding's client address is inside the address or network.

The usual reasons are:

  • Antivirus and endpoint products that look up file hashes or reputation data over DNS.
  • DNS blocklists that encode the address to check in the name.
  • Software update checks and telemetry that put version or session data into labels.
  • Monitoring tools that probe resolvers with generated names.

Prefer excluding the domain over the client. A domain exclusion covers every client that uses the product, while a client exclusion hides whatever that client does next.

Use Exclude on a finding page to create an exclusion that is pre-filled from that finding. A finding that matches an enabled exclusion is not created and does not raise an alert. Existing findings that match are marked as excluded and are no longer updated; the exclusion page shows them and can delete them.

Alerts

DNS tunnel detection can raise one kind of detection alert. It is disabled by default and is enabled in the configuration:

Type Raised when
DNS_TUNNEL A new DNS tunnel finding is detected.

The alert is raised once per finding, not again while it continues. A finding that is later recorded at another location raises an alert there. It carries the client, the domain, the indicators, a sample of the names, the resolvers and the counts at the time of the alert, and links to the finding.

Configuration

Users with the Manage Ethernet Monitoring permission can change the detection parameters on the Settings tab. Exclusions and the settings are kept when findings are deleted.

Key Default Description
Detection enabled true Run DNS tunnel detection for the tenant.
Detection window (Minutes) 10 Queries are counted inside this window, and a finding stays open while the client keeps querying inside it. Between 1 and 1440.
Minimum distinct names in window 50 How many different names the client must have looked up under the domain inside the window before the indicators are checked. Between 1 and 100000.
Entropy threshold (Tenths of bits per character) 35 Average entropy of the labels below the registered domain that sets the HIGH_ENTROPY indicator. 35 means 3.5 bits per character. Between 1 and 80.
Name length threshold (Characters) 30 Average length of the labels below the registered domain that sets the LONG_NAMES indicator. Between 1 and 253.
Unusual record type share threshold (Percent) 50 Share of TXT, NULL, CNAME, MX, KEY and SRV queries that sets the UNUSUAL_RECORD_TYPES indicator. Between 1 and 100.
Finding retention time (Days) 365 How long findings are kept. Between 1 and 3650.
Alert on new DNS tunnel finding false Raise DNS_TUNNEL alerts.

Retention

Findings follow the finding retention time configured above and are removed at the start of a detection run once they have not been seen for that long. Detection reads the DNS transaction log, so it cannot see further back than that log is retained, and the link from a finding to the raw transactions only works while they are. See Configuring Retention Times for how to change retention times.