
DNS Tunneling
DNS tunneling is a technique that hides other data inside ordinary Domain Name System (DNS) lookups and replies, so it can pass through permitted DNS traffic when controls do not detect or restrict it. Security testers use it, and attackers use it to send commands to a compromised device or move stolen data out of a network.
CyberRecaps is supported by its readers. We may earn an affiliate commission at no extra cost to you if you buy through a link on this page.


Explain It Like I'm 10
Think of a school library where the helper at the front desk will look up any book you ask for. She does not keep every book herself, so she passes your request along to whoever looks after the right shelf, and the answer travels back the same way.
Now two friends agree on a trick. One writes a secret message into the book title she asks for. The helper does not read titles closely, so she passes the request along, and it reaches the friend who looks after that shelf. That friend slips a reply into the note that comes back. The helper only ever carried titles and notes, yet two people were talking through her desk. A more careful helper, who checked titles against a list of known tricks, could refuse the ones she recognised. DNS tunneling works in roughly this way.
DNS Tunneling Quiz
Test your knowledge about DNS Tunneling - maybe you already know everything about it.
What does DNS tunneling hide inside ordinary DNS lookups and replies?

What happens in a normal DNS lookup?
Every device on the internet has an IP address, a number other devices use to find it. People use names instead, and the Domain Name System connects the two. As ICANN puts it, "your device uses the DNS to look up the domain name and find its associated IP address."
The device rarely asks the owner of the name directly. It asks a resolver, a program that looks names up on its behalf. If the resolver does not already have the answer, it asks other servers and returns what it finds. At the end of that chain is the authoritative server for the domain, the server that can answer for it without asking anyone else.

How does DNS tunneling work?
DNS tunneling uses that ordinary chain as a carrier. MITRE ATT&CK, a globally accessible knowledge base of adversary tactics and techniques, describes attackers using DNS to communicate with systems under their control, with commands and often their results embedded in the traffic between client and server. It notes that the practice is often known as DNS tunneling.
What the attacker needs
In the common set-up, the attacker needs two things. The first is control over how a domain, or a subdomain delegated to them, is answered, together with a server that does the tunnel's receiving work. Palo Alto Networks describes this as control of a domain and a server that processes the queries. The second is software on a compromised device inside the target network, which acts as the tunnel's client.
Control is the condition, not ownership of a registered domain. DNS lets the holder of a domain hand responsibility for a part of it, such as a subdomain, to other servers. RFC 9499 calls this delegation, so an operator who controls a delegated subdomain meets the same condition. This is the common architecture, not a checklist for every implementation.
How data goes out
To send something out, the software puts the data into the name it asks the resolver to look up. The name ends in a domain the attacker's server answers for, with the data placed in front of it as a subdomain. MITRE documents a backdoor that encodes data in the subdomain field of DNS packets, and an intrusion in which data was encoded and prepended as subdomains to a domain the attackers controlled.
An ordinary resolver does not judge what a name means. Its job is to find the server that answers for that domain, so it passes the lookup on, and the lookup can reach the attacker's server, which reads the data out of the name. A security-aware resolver can inspect lookups and refuse to resolve names it knows to be malicious, so whether a tunneled lookup gets through depends on the resolver's controls, as the defenses below show.
How instructions come back
The attacker's server then answers like any other server for its domain, but the answer carries a message. Commands can be embedded in DNS records. The resolver hands the answer back to the device as it would any answer, and the software reads its instruction.
One lookup carries little. A domain name has a maximum length, so a large transfer is split across many lookups, and a conversation becomes a long series of lookups and answers.

Why can DNS tunneling pass through a network?
Once the lookup leaves the device, each step is ordinary DNS behaviour. What is unusual is the purpose of the names, and several features of DNS make that purpose easy to hide when controls do not look for it:
- DNS is common and can be allowed early: DNS can be very common in a network, and its traffic can be allowed even before a device has finished authenticating.
- The path is the normal path: a tunneled lookup travels the same route as every other one, from the device to its resolver and outward to the server that answers for the domain.
- Names can hold almost anything: there are very few restrictions on what a DNS request contains, and DNS packets have many fields and headers in which data can be concealed.
- Limited logging can hide it: many DNS logs record domain names rather than the content of replies, so the return channel is hard to see. That does not make query logs ineffective, because the full queried names can show encoded subdomains and suspicious patterns. Palo Alto Networks warns that without visibility into record types such as TXT, or into unusually long subdomain queries, tunnels often remain invisible.

What is DNS tunneling used for?
Command and control
Command and control, usually shortened to C2, is how an attacker steers software on compromised machines: instructions go in and results come back. DNS can carry both directions: results go out in the names, and commands come back in the replies.
Infoblox described the same idea running on compromised websites rather than workstations. The infected sites themselves, not their visitors' browsers, sent DNS lookups to servers the actor controlled, and the replies told each site what to do. Most of the time the reply was to do nothing and show the site as usual. Infoblox suspects the actor limits redirects in part to avoid detection. From June 2025, some replies sent infected sites to fetch content from command servers of the Strela Stealer malware. Infoblox says it has tracked the actor since August 2023, and it published this report on 30 September 2025.
Two things stand out: the software making the lookups was a website, not a person's device, and the names carried data, including a subdomain with information about the visitor.
Moving data out
The same carrier works for exfiltration, the theft of data from a network. MITRE records DNS lookups used to send victim data out, and which technique applies depends on the channel.
T1048.003, exfiltration over an unencrypted protocol other than the existing command-and-control channel, fits data sent over DNS separately from that channel. It is not the mapping for every case of DNS exfiltration. Data sent out over a DNS command-and-control channel that is already in use maps instead to exfiltration over the existing command-and-control channel, T1041.
Legitimate uses
The technique is not only an attack. Palo Alto Networks says security teams test it to see how it might get past their defenses, and that researchers use it in controlled settings to study how malware behaves and how attackers communicate with infected systems.

How is DNS tunneling different from C2, exfiltration and other DNS abuse?
DNS tunneling is one carrier, so it sits beside several terms that name goals or other techniques:
- Command and control: the goal of steering compromised machines. DNS tunneling is one way to carry that traffic.
- Data exfiltration: the goal of getting data out. DNS tunneling is one route. Exfiltration over a web service sends data to a legitimate online service instead, while DNS tunneling sends it to a server the attacker runs.
- Protocol tunneling: the general idea of wrapping one protocol's traffic inside another, which MITRE lists as T1572. MITRE files DNS-based command and control as T1071.004; the exfiltration mapping depends on the channel, as the exfiltration section above explains.
- DNS used to find a server: techniques such as domain generation algorithms and fast flux change which names or addresses malware contacts, so the malware can reach its server. Neither is tunneling by itself, because neither carries other data inside the DNS messages, but they can appear alongside tunneling and other techniques in the same campaign.
Encrypted DNS is a different layer
DNS over HTTPS (DoH) and DNS over TLS (DoT) are two ways of sending DNS messages inside encrypted connections. They concern how the messages travel. DNS tunneling concerns the data carried inside the messages, so a tunnel can use either transport: Unit 42 describes a tunneling tool that can use DoH and DoT to provide privacy and evade detection.
Encrypted DNS also has legitimate privacy and security uses. The UK's NCSC, for example, offers a roaming service that sends a device's DNS traffic over DoH to a protective resolver, which declines to resolve known-malicious domains, when the device is outside the office network. The enterprise concern is unauthorized resolver use and loss of visibility, not encryption by itself. MITRE separately notes that DoH can be used to resolve the attacker's command servers, which is a different use from carrying data in the names.

How do defenders see and limit DNS tunneling?
The obvious defense, blocking DNS, is not so simple. The protocol is foundational to network communication, so defenders layer several controls instead. Each layer has a limit.
Route lookups through a resolver you control
A common first control is to make an approved resolver the required route for lookups. MITRE lists as a mitigation that resolving DNS requests with on-premises or proxy servers can disrupt attempts to conceal data in DNS packets. Centralizing gives defenders one place to inspect, log and enforce policy before lookups reach external resolvers. Centralization alone does not stop a tunnel; what stops it is what the organization does with that visibility.
Naming an approved resolver is not enough, because it has to be enforced. CISA's guidance for US federal civilian agencies describes two parts:
- Managed endpoint and application settings: set centrally, so that encrypted DNS is used only with authorized services and built-in encrypted DNS in applications is switched off where it would bypass them.
- Network controls: block endpoints from reaching unauthorized DNS paths, including encrypted DNS to unauthorized resolvers.
Approved encrypted DNS services stay allowed. Palo Alto Networks gives the same advice for DoH: allow only resolvers you manage or monitor.
The limit is the devices that go around it, and the visibility lost when DNS is encrypted. CISA warns that DNS encryption can hinder network tools that depend on seeing unencrypted DNS, so it asks agencies for comparable visibility from endpoint-based sources. Palo Alto Networks adds that devices sending DNS over HTTPS can bypass enterprise controls.
Refuse known-bad domains
A protective resolver answers lookups but declines to resolve malicious domains it knows about. The UK's NCSC runs one for eligible UK organisations, and says it "prevents access to domains known to be malicious, by simply not resolving them." CISA provides a similar service to US federal civilian agencies, with visibility into the domains they resolve.
The limit is the word "known." A domain that has not yet been identified as malicious is not covered. In the 2025 case above, Infoblox reports that after the Shadowserver Foundation sinkholed the actor's command domain, so that the infected sites' queries reached the Foundation instead, the actor set up a new one within hours.
Look at the pattern of lookups
A tunnel moves its data through names and answers, and a large transfer needs many lookups, so the traffic can look different from a person browsing. MITRE's detection strategy for DNS tunneling includes checks for clients sending queries at high volume with long subdomains or encoded-looking patterns, and for DNS queries sent by processes that are not browsers or system components.
Detection works best when several signals are read together: the full query names, the relevant responses, the timing of the lookups, and which endpoint and process sent them. Palo Alto Networks recommends reviewing responses as well as queries. CISA notes that a protective resolver's logs may need additional context to identify the endpoint behind a request, and that device logs can add it.
This has three limits:
- Each sign can be benign: any one of them can have an innocent cause, and Palo Alto Networks says some tunneling-like activity comes from legitimate services such as consumer VPNs.
- A tunnel can be slow: a beacon, a device's periodic check-in with its server, can be hard to detect when it communicates infrequently, because that hides it among normal DNS traffic.
- Attackers can design around a volume signal: Kaspersky reported that the DNS exfiltration plugin of the ProjectSauron toolkit, disclosed in 2016, ran in low-bandwidth mode to avoid generic network detection of DNS tunnels.