DNS tunneling: spotting data hidden in DNS queries

DNS tunneling encodes data in query names to slip past filters that allow DNS. How it shows up in resolver logs or Zeek dns.log as long, high-entropy subdomains to one domain, and how to detect and block it.

Lesson 15 of 16 · 10 min read · practice only with authorization

Diagram

Tunneling in resolver logs

Follow the path. One example at a time.

Step 1 of 4

Normal

Queries for a few well-known names.

Illustration: Normal
www.example.com  A
login.microsoftonline.com  A

The example on the open step is one illustration, or the fix you can paste into an application you own.

What this page is made of

3 pieces. Each one says what fails, who is affected, what you would notice, and what you change.

  1. Long, random labels

    What fails
    Encoded data produces long labels with high entropy.
    Who is affected
    Data on the host doing the queries.
    What you would notice
    Average query length above about 50 characters for one domain.
    What you change
    Alert on length and entropy per base domain.
  2. Unusual record types

    What fails
    TXT and NULL records carry more data per response.
    Who is affected
    The same.
    What you would notice
    Many TXT queries from a workstation.
    What you change
    Baseline record types per host role.
  3. Direct DNS

    What fails
    Hosts that talk to outside resolvers bypass your logs.
    Who is affected
    Visibility.
    What you would notice
    Port 53 traffic to external IPs.
    What you change
    Allow DNS only to your resolvers and log them.

Where to look

Resolver query logs (Windows DNS analytic logs, BIND query logs, Route 53 Resolver logs) and network sensors such as Zeek and Suricata all see the queries. Protective DNS services score domains too. The Suricata lessons in the tool library show DNS-focused rules.

Check yourself

Recognition and the fix. Nothing here is a procedure.

1 / 3

Which pattern suggests DNS tunneling?

Sibling techniques

Pages at the same depth, plus a lab and a glossary card for this one.

This page stands on its own. The lab and the glossary card are the next reading.

Practice

  1. LabTerminal mission: File names leaving in DNS queriesTXT lookups with long hex labels leave one client every minute. Extract the labels, decode them, map the client IP to a laptop through DHCP, and find the process from EDR.

Glossary

  1. CardDNS tunnelingData or a command channel hides inside DNS queries, which almost every network allows.