How does DNS tunneling sneak data out of a network?
DNS tunneling is a trick where malware hides data inside DNS (Domain Name System) lookups, the questions a device asks to find a website's address, so it slips out through a door most networks leave open.

DNS tunneling
Before your device opens a website, it asks a server for the site’s numeric address. That question is a DNS (Domain Name System) lookup. DNS tunneling is a trick that hides other data inside those questions and their answers. Malware uses it to sneak stolen data out of a network and to pull orders back in.
The trick works because DNS usually travels on UDP (User Datagram Protocol) port 53, a door most networks leave open. Normal DNS traffic is also huge, so extra lookups are easy to hide in it. That’s why the defense lives at the DNS layer itself: in DNS logs and in resolvers that block known-malicious domains.
What DNS tunneling actually sends
The attacker first registers a domain. Through the registrar, they put an NS (name server) record and a glue address record in the parent zone. Those records send every resolver to the attacker’s own server, which becomes the authoritative nameserver for that domain.
Malware then writes the data into the name it looks up. Each piece between the dots, called a label, holds at most 63 characters, and a whole name at most 255 bytes. As an illustration, the word secret is ONSWG4TFOQ in Base32, so a query could look like ONSWG4TFOQ.evil.example. A real query from a campaign Unit 42 called FinHealthXDS looked like txt.1f0522f1e.3074aa20643.62c1b4ba.novel.foxxbank[.]com. Answers can carry data too, in A, AAAA, TXT, CNAME (canonical name) and MX (mail exchange) records.
How the tunnel works, step by step
- The attacker owns the nameserver. The domain points to a server the attacker controls. Any lookup for a name under that domain ends up there.
- Malware hides the data. Software on a company laptop encodes stolen data into labels. Each label stays under 63 characters, so the data becomes many lookups.
- The resolver walks the tree. The laptop asks the company’s own DNS server, the resolver. The resolver walks down the DNS tree and asks the attacker’s server.
- The reply carries orders. The answer hides commands in an IP (Internet Protocol) address, an alias record or a
TXTrecord.
The result is a two-way channel where the laptop never touches the attacker. In 2020, the SUNBURST backdoor in SolarWinds software used this setup. Its C2 (command and control) coordinator was the authoritative DNS server for avsvmcloud[.]com. In its first mode, lookups hid the victim organization’s network domain in subdomains of that domain. A CNAME reply named its HTTPS (Hypertext Transfer Protocol Secure) C2 server.
DNS tunneling is not a firewall problem
Many people think a strict port firewall would stop this. It doesn’t. The laptop only talks to the company’s trusted resolver on port 53, and that traffic is allowed on purpose. The resolver does the talking to the attacker’s server as part of its normal job. The fix belongs at the DNS layer, where the names themselves can be logged, checked and blocked.
What to do
- Set your phone’s Private DNS to
dns.quad9.net. On Android, open Settings > Network & internet > Private DNS, choose Private DNS provider hostname, enter it and tap Save. On Samsung, it’s Settings > Connections > More connection settings > Private DNS. Quad9 blocks known-malicious domains, but not every new tunnel. - If you run a network, let devices send DNS only to your company resolver and keep DNS logs, for example the
dns.logthat Zeek writes. - Look for the signs in those logs: long random names, bursts of lookups to one domain, and lookups from PowerShell instead of browsers.
- On Windows, Sysmon Event 22 records each DNS query with the process that made it. It’s a free tool you must install, and it only sees queries that go through the Windows DNS Client, so direct lookups such as
nslookupare missed.
Watch it in 60 seconds
