Skip to content
Threat Intelligence

Detect DNS Tunneling: Log Analysis and Network Signatures

Standard firewalls often miss DNS tunneling because the traffic uses port 53 and mimics legitimate domain name resolution queries from authorised clients.

Illustration: A tangled knot of thin, glowing blue threads weaves through a rigid, transparent grid structure, slipping unnoticed between the solid bars.
AI-generated illustration: Cipher Insider
Quick answer

Monitor for unusually long domain names, high query volumes from single hosts, and excessive TXT record usage. Analyse entropy levels in subdomains to identify encoded data streams. Compare traffic patterns against known baseline behaviour to isolate anomalies that bypass standard perimeter defences.

Understanding the DNS Tunneling Mechanism

Domain Name System tunneling abuses the DNS protocol to move data outside a network. The Domain Name System translates human-readable domain names into IP addresses. Attackers encode information within the domain names themselves. They use subdomains to carry payloads. This method bypasses firewalls that allow DNS traffic. The traffic looks like normal name resolution. You must understand the protocol limits to detect abuse.

DNS has a maximum label length of 63 characters. The total domain name cannot exceed 253 characters. Attackers split large data into smaller chunks. They send these chunks as separate queries. The responses may carry data back. This creates a covert channel. You are looking for deviations from standard usage. Normal DNS queries are short and infrequent. Tunneling queries are long and frequent. The volume is the first indicator. The structure is the second.

Infographic: Detect DNS Tunneling: Log Analysis and Network Signatures. High entropy in subdomain labels indicates encoded data rather than human-readable hostnames. Legitimate DNS traffic rarely uses TXT records for large data transfers or maintains persistent long-lived connections. Standard firew
Infographic: Detect DNS Tunneling: Log Analysis and Network Signatures. Free to share with a link to Cipher Insider.

Analysing Query Volume and Frequency

Standard users do not generate thousands of DNS queries per minute. A single workstation might make a few dozen queries an hour. Tunneling tools automate the process. They send queries in rapid succession. You see a spike in query rates from one source IP. This source often talks to a single external domain. The domain may be newly registered. It may have no web presence. The frequency is unnatural. Human behaviour is sporadic.

Automated tools are rhythmic. Look for consistent intervals between queries. This rhythm suggests a script. It does not suggest a user browsing the web. High volume alone is not proof. Large organisations have high DNS traffic. You must correlate volume with source. One host causing 10 per cent of traffic is suspicious. One host causing 50 per cent is likely malicious. Track the baseline for your environment. Deviations from the baseline trigger alerts.

Inspecting Domain Name Entropy

Entropy measures the randomness of data. Human-readable words have low entropy. They follow language patterns. Common letters appear frequently. Random strings have high entropy. All characters appear with equal probability. Tunneling tools encode data into base64 or hexadecimal. This creates random-looking strings. These strings become subdomains. You can calculate the Shannon entropy of the subdomain. High entropy scores indicate encoded data.

Low entropy scores indicate normal hostnames. This metric is powerful. It catches tunneling even if the domain is not blacklisted. The domain registrar may be legitimate. The parent domain may be benign. The subdomain is the carrier. Focus your analysis on the subdomain part. Ignore the top-level domain. The randomness is the signal. You need tools that calculate entropy in real time. Standard log viewers do not do this.

Reviewing Record Types and Response Sizes

Standard DNS uses A records for IPv4 addresses. It uses AAAA records for IPv6 addresses. TXT records store text information. They are used for email verification and security keys. Tunneling tools prefer TXT records. They can hold larger payloads. A single TXT record can carry 255 bytes. Attackers use this capacity. They send data in the query. They receive data in the response. The response size is large. Normal A record responses are small.

They contain only an IP address. Large responses suggest data transfer. Monitor the size of DNS responses. Look for TXT records with large payloads. Look for NULL records. Look for CNAME records that point to other CNAMEs. This chaining is unusual. It increases latency. It obfuscates the final destination. Check the TTL values. Time To Live values control caching. Tunneling tools often set low TTLs. They want fresh data every time. They do not want cached results.

Identifying Persistent Connections and Timing

DNS is a stateless protocol. Queries are independent. Tunneling tools often maintain state. They keep a connection open. They use long-lived queries. They wait for responses. This creates a persistent flow. Standard DNS resolves quickly. It does not hang. Look for queries that take seconds to resolve. Look for repeated queries to the same subdomain. This suggests a keep-alive mechanism. The attacker wants the channel open.

They send heartbeat packets. These look like normal queries. They are not. The timing is the key. Regular intervals indicate automation. Irregular intervals indicate human use. You can plot the query times. A flat line is suspicious. A jagged line is normal. This analysis requires detailed logs. You need timestamp precision. Standard logs may round to the minute. Minute-level precision hides the rhythm.

See also: Common Threat Intelligence Platform Mistakes and Fixes · Port Scanning Myths: What Attackers Actually Reveal

Common Blind Spots in Detection

Many security tools ignore DNS traffic. They assume it is safe. Port 53 is allowed by default. Firewalls do not inspect the payload. They check the destination IP. The destination is a resolver. Resolvers are trusted. This trust is the blind spot. Attackers exploit this trust. They route traffic through public resolvers. They avoid internal DNS servers. This bypasses internal monitoring. You must monitor egress traffic. You must inspect DNS packets.

Deep packet inspection is required. Signature-based detection fails. New tunneling tools change their signatures. Behaviour-based detection works better. It looks for patterns. It does not look for specific strings. Another blind spot is encrypted DNS. DNS over HTTPS encrypts the query. You cannot see the domain name. You see only the destination IP. This hides the tunneling. You must monitor for DoH usage. Unauthorised DoH is a red flag.

SignalWhere to lookWhat it may mean
High query volumeDNS server logsAutomated data exfiltration or command and control
High entropy subdomainsSubdomain stringsEncoded data payload within the query
Large TXT responsesResponse payloadsData being returned to the attacker
Low TTL valuesRecord headersDesire for real-time data, avoiding cache
Irregular query timingTimestamp logsHuman activity versus automated scripts

Integrating Threat Hunting Practices

Detection is reactive. Hunting is proactive. You search for indicators of compromise. You look for what is missing. You look for what is different. This approach complements automated alerts. You can use threat hunting to find tunneling. You start with a hypothesis. You assume tunneling is happening. You test this assumption. You look for high entropy.

You look for high volume. You look for unusual record types. This method finds new tools. It finds custom scripts. It finds variants. You must update your signatures. You must refine your baselines. This is an ongoing process. The attackers change their methods. You must change your methods too. See our guide on threat hunting for broader techniques.

Mitigating the DNS Tunneling Risk

Prevention is difficult. DNS is required for internet access. You cannot disable it. You can restrict it. Use DNS filtering. Block known malicious domains. This stops known tunneling. It does not stop new tunneling. Use DNS sinkholing. Redirect suspicious queries to a safe server. This captures the traffic. You can analyse it. You can identify the source.

This helps with incident response. See our guide on attacker persistence techniques for related risks. Attackers use DNS for persistence. They set up scheduled tasks. They use DNS for communication. You must monitor for these tasks. Check for unusual DNS clients. Check for DNS services running on workstations. They should not be there. Only servers should run DNS services.

Key takeaways

  • High entropy in subdomain labels indicates encoded data rather than human-readable hostnames.
  • Legitimate DNS traffic rarely uses TXT records for large data transfers or maintains persistent long-lived connections.
  • Standard firewalls often allow DNS traffic by default, creating a blind spot for exfiltration via port 53.
Bottom line

DNS tunneling hides in plain sight by abusing standard protocol features. Monitor for high entropy, unusual record types, and abnormal query volumes to catch it.

Frequently asked questions

Does DNS over HTTPS prevent tunneling detection?

DNS over HTTPS encrypts the query content, making it invisible to network monitors. You must monitor the destination IP and volume instead of the domain name.

Can I block DNS tunneling with a firewall?

Standard firewalls cannot inspect DNS payloads effectively. You need a dedicated DNS proxy or firewall with deep packet inspection capabilities to analyse the query structure.

What is the difference between DNS tunneling and DNS amplification?

DNS tunneling uses DNS to exfiltrate data or receive commands. DNS amplification uses DNS to flood a victim with traffic. Tunneling is slow and covert. Amplification is fast and loud.

How do I calculate DNS query entropy?

Use Shannon entropy formulas on the subdomain string. High entropy values indicate randomness. Low entropy values indicate readable text. Many security tools calculate this automatically.

How this guide was produced: written by the Cipher Insider editorial team with AI assistance, checked against the public references listed below, and reviewed when the facts change. See our editorial policy or report an error.

Further reading

  1. FIRST: Forum of Incident Response and Security Teams
  2. MITRE ATT&CK
  3. MITRE D3FEND
DNS tunnelingdns securitynetwork analysislog monitoring

Related stories

DNS over HTTPS vs DNS over TLS: Protocol Differences and Choice

DNS over HTTPS embeds queries within standard web traffic, hiding them from network inspection tools that rely on port analysis, whereas DNS over TLS uses a dedicated encrypted channel that remains distinct from general web browsing.