4 Dec 2026Security news updated around the clock

DNS Tunneling

DNS tunneling hides commands or stolen data inside DNS queries and replies so malware can talk through a protocol almost every network allows.

Network & Cloud SecurityIntermediateUpdated

What is DNS Tunneling?

DNS tunneling is a technique that hides other data inside DNS queries and replies, so a compromised device can exchange commands with an attacker's server or send data out through the one protocol that almost every network lets through. The device never connects to the attacker directly. It asks the company's own DNS resolver to look up odd-looking names, and the resolver carries the traffic across the internet for it.

The business impact is quiet data loss and command channels that survive other controls. A firewall that blocks unknown web traffic and a proxy that inspects HTTPS will often still pass DNS. The channel is slow, so attackers use it for commands, credentials, and small, high-value files rather than bulk theft.

Security leaders should care because DNS is often logged badly or not at all. If nobody can answer "which internal hosts sent thousands of lookups to one new domain yesterday", this channel is open.

How DNS Tunneling works

  1. The attacker registers a domain and runs the authoritative name server for it, so every lookup under that domain ends up on their server.
  2. Malware on an internal host encodes data, often as base32 or hex, into the leftmost labels of a name such as <encoded-chunk>.t.attacker-domain.example.
  3. The host asks the internal resolver for that name. The resolver has never seen it, so it forwards the question across the internet to the attacker's server.
  4. The attacker's server decodes the label and sends instructions back inside the reply, using TXT, NULL, CNAME, or even A records.
  5. The loop repeats every few seconds. Each query carries a small chunk, and together they form a two-way channel.
flowchart LR
  A["Malware on internal host"] --> B["Internal DNS resolver"]
  B --> C["Internet DNS hierarchy"]
  C --> D["Attacker's authoritative server"]
  D -->|"Commands in TXT or CNAME replies"| C
  C --> B
  B --> A

Under the hood

Where the data hides

DNS names have hard limits: each label can be at most 63 bytes, and the whole name at most 255 bytes on the wire. After encoding overhead, one query carries well under 200 bytes of real data upstream. Replies carry more. A TXT record holds strings of up to 255 characters each and can contain several of them, which is why tunnels prefer TXT for downstream traffic.

Common tools show the range. iodine builds a full IP-over-DNS link. dnscat2 provides an encrypted command channel. Many malware families include their own simple encoders. DNS over HTTPS (DoH) adds another layer, because the queries then travel inside normal-looking HTTPS to a public resolver and never appear in your DNS logs.

What it looks like on the wire

A tunnel produces traffic that breaks normal DNS patterns:

  • many unique subdomains under one registered domain, often thousands per hour from one host
  • long labels made of random-looking characters, which scores high on Shannon entropy
  • heavy use of TXT or NULL record types from workstations
  • regular timing, because the implant polls on a fixed interval
  • many NXDOMAIN answers, or replies that are much larger than usual
# Example of a suspicious name in Zeek dns.log (query, qtype)
mzxw6ytboi2dqnjqgy3tmmbqgmzdg.4f2a.t.attacker-domain.example   TXT

The key analysis step is to group queries by registered domain (the part a person can buy, such as attacker-domain.example) rather than by full name, then count unique subdomains and average label length per group.

Framework mapping

T1071.004 covers DNS used as a command channel. T1572 covers wrapping another protocol, such as IP traffic, inside DNS. T1048 covers moving stolen data out over a protocol other than the main command channel.

Common attack scenarios

  • A law firm blocks all outbound web traffic from its document server except through a proxy. Malware on the server sends scanned contracts out over DNS at a few kilobytes a minute for two weeks before anyone notices.
  • A point-of-sale network allows only DNS to the internet. Attackers exfiltrate card data as encoded subdomains, one transaction per query.
  • A developer installs a VPN-over-DNS tool to get around a hotel captive portal and forgets it on a company laptop. The SOC flags it as tunneling, which is correct, and the alert turns into a policy conversation rather than a breach.

Framework mappings

Latest real-world attacks using this technique

News stories tagged with DNS Tunneling. This list updates on its own while the page is open.

    No news stories are tagged with this topic yet.

    Prevention, hardening and detection

    Prevention and hardening

    • Force all endpoint DNS through your own resolvers. Block outbound TCP and UDP port 53 and DNS over TLS on port 853 from everything except those resolvers.
    • Decide how you handle DoH. Either block known public DoH resolvers and disable DoH in browsers through policy, or run your own DoH service that logs every query.
    • Use a protective DNS service or response policy zones that block known tunneling domains, newly registered domains, and domains from low-reputation registrars.
    • Restrict which hosts may resolve external names at all. Many servers only need internal names and a short list of update domains.

    Detection

    Data sourceWhat to look forExample
    Resolver or Zeek dns.logUnique subdomains per registered domain per host4,000 unique names under one domain in an hour
    Resolver or Zeek dns.logLong, high-entropy leftmost labelsAverage label length above 40 characters
    Resolver or Zeek dns.logTXT or NULL queries from workstations900 TXT lookups from a laptop in a day
    Firewall or NDR flowsDNS traffic that bypasses internal resolversWorkstation sending UDP 53 straight to an internet IP
    Proxy logsHTTPS to public DoH endpoints from unmanaged softwareConnections to a DoH resolver from a server

    Expect some noise. Antivirus reputation checks, CDNs, and some security products use long DNS names on purpose. Build an allow-list of these after a week of baselining, then alert on the rest.

    Frequently asked questions

    Can a firewall stop DNS tunneling?

    A firewall can force DNS through your resolvers and block direct port 53 traffic to the internet. It cannot judge the content of a query, so the tunnel still works through your own resolver unless you filter domains or analyze query patterns.

    How much data can DNS tunneling move?

    Each query carries only a small chunk, so tunnels run at kilobytes per second at best. That is too slow for bulk theft but plenty for commands, passwords, and sensitive documents over days or weeks.

    Does DNS over HTTPS make tunneling harder to detect?

    Yes. With DoH, lookups travel inside HTTPS to a public resolver and skip your DNS logs. Block or control DoH so that all lookups still pass through a resolver you can see.

    Is all DNS tunneling malicious?

    No. Some VPN products, captive portal workarounds, and security tools use DNS this way on purpose. Treat each alert as an unapproved channel first, then decide whether it is a policy issue or an intrusion.

    References and further reading