Insights

Thinking Your Firewall Blocked the Attack Because Logs Show No Drops? Check for DNS Tunneling

November 16, 2026
0:00
Your firewall logs show zero dropped or denied connections during a suspected breach window. Every outbound connection on ports 80, 443, and the usual suspects looks clean. No alerts fired. So you conclude nothing left the network. This assumption is wrong, and it is wrong in a way that is hard to catch after the fact: data can leave your network encoded inside ordinary DNS queries, on port 53, which nearly every firewall allows outbound without inspection.
Firewalls typically log denied connections. If your policy allows outbound DNS (port 53 UDP/TCP) — and almost every network does, because things break immediately when you block it — then DNS traffic never appears in your deny logs. It is allowed traffic. It looks normal. DNS tunneling exploits this by encoding stolen data into the query itself. Instead of resolving www.example.com, the compromised host sends queries like dG9wc2VjcmV0ZGF0YQ.exfil.attacker.com. That long subdomain label is base32 or base64 encoded payload. The authoritative nameserver for attacker.com receives the query, strips out the encoded chunk, and reassembles the exfiltrated data on the other side. The response path works too. TXT records can carry up to around 255 bytes per string (multiple strings per record), so the attacker's nameserver can send commands or additional tooling back inside DNS responses. Tools like iodine and dnscat2 automate this entire process, creating a bidirectional tunnel over DNS that looks — to your firewall — like ordinary name resolution. Your firewall did its job. It enforced the rules you gave it. The problem is that the rules say "allow DNS," and the attacker used DNS.
Normal DNS queries have short, human-readable labels. mail.google.com is 15 characters. cdn.shopify.com is 15 characters. Legitimate subdomains rarely exceed 30-40 characters total. DNS tunneling queries look different in three measurable ways: Query length. RFC 1035 allows each label (the part between dots) to be up to 63 bytes, and the total query name up to 253 bytes. Tunneling tools pack as much data as possible into each query, so you see labels approaching those limits. A query like aGVsbG8gd29ybGQgdGhpcyBpcyBhIHRlc3Q.x.data.attacker.com is already suspicious just by length. Entropy. Normal domain names use common letter patterns — vowels, consonants, recognizable words. Base32/base64 encoded data has high Shannon entropy because the character distribution is nearly uniform. A label like r4nd0mstr1ng8f has noticeably higher entropy than mail or login. Record type distribution. Normal clients mostly send A and AAAA queries. DNS tunneling often uses TXT, CNAME, or NULL record types because they can carry more data per response. A sudden spike in TXT queries from a single internal host, especially to a domain you have never seen before, is a strong signal.
Most people do not log DNS queries at all, which is the first problem. If you run a local resolver (BIND, Unbound, dnsmasq, or whatever your control panel ships), query logging is typically off by default for performance reasons. You need to enable it, or capture DNS traffic at the network level. If you have packet captures or can start one, tshark (the command-line version of Wireshark) can extract DNS queries quickly:
BASH
# Extract DNS query names longer than 50 characters from a pcap file
tshark -r capture.pcap -Y 'dns.qry.name and dns.flags.response == 0' \\
  -T fields -e dns.qry.name | awk 'length > 50'
This filters for DNS queries (not responses) and prints only those where the full query name exceeds 50 characters. In normal traffic, very few queries hit that length. In a tunneling scenario, you will see hundreds or thousands. For live monitoring on a server that runs its own resolver, you can watch queries in real time. On BIND, enable query logging temporarily with rndc querylog on and tail the log. On Unbound, set verbosity: 2 or higher in unbound.conf and restart. On systemd-resolved, resolvectl monitor shows queries as they happen. The exact method depends on your resolver and distribution. Once you have query logs, look for these patterns:
BASH
# Count queries per domain, sorted by frequency — illustrative command
awk -F'.' '{print (NF-1)"."NF}' dns_queries.log | sort | uniq -c | sort -rn | head -20
This groups queries by their registered domain (last two labels). Normal traffic spreads across many domains. Tunneling concentrates thousands of queries against a single domain the attacker controls.
Eyeballing query names works when you have ten suspicious entries. When you have ten thousand queries to review, you need a quick entropy calculation. Shannon entropy measures how random a string is — low entropy means repetitive or structured (like www.google.com), high entropy means uniform character distribution (like base64 data). A rough threshold: normal domain labels typically have entropy below 3.5 bits per character. Encoded tunneling labels tend to land above 4.0. These are rules of thumb, not hard cutoffs — some legitimate services (CDNs, anti-spam tokens, DKIM selectors) produce high-entropy subdomains too. But when you see high entropy combined with high query volume to a single domain, and the record types are mostly TXT or NULL, that combination is rarely innocent. You can compute entropy with a short script in Python, Perl, or awk. The math is straightforward: for each character in the label, calculate its frequency, then sum -p * log2(p) across all characters. Many DNS analysis tools (like freq.py from SANS or the dns module in Zeek/Bro) compute this automatically.
You do not need a commercial SIEM to catch DNS tunneling. Here is a minimal checklist using tools already on most Linux servers: 1. Enable DNS query logging. Even temporarily during an investigation. The performance cost is real on busy resolvers, so on production systems you might prefer packet capture on port 53 with tcpdump -w /tmp/dns.pcap -i any port 53 for a bounded time window instead of permanent query logging. 2. Look for volume anomalies. Count queries per source IP per hour. A workstation sending 50 DNS queries per hour is normal. One sending 5,000 queries per hour to a single domain is not. 3. Check query name length. Any consistent pattern of queries with labels longer than 40-50 characters warrants investigation. 4. Check record types. Filter for TXT and NULL queries. If a single internal IP is generating hundreds of TXT queries to one external domain, investigate that domain. 5. Inspect the target domain. Run a WHOIS lookup. Check when it was registered. Tunneling domains are often freshly registered, use privacy protection, and have no web presence. The authoritative nameserver might be a VPS with no reverse DNS. If you run a DNS resolver that supports response policy zones (RPZ), you can block known tunneling domains or entire categories of newly registered domains. This is a blunt tool — it will cause false positives — but it raises the cost for the attacker.
The core misconception is treating firewall logs as a complete record of what left the network. Firewalls log policy decisions: allow or deny. If your policy allows DNS, the firewall has nothing to report. The data leaves in plain sight, encoded in the query string, through a protocol you explicitly permitted. This same blind spot applies to other covert channels — HTTP headers, ICMP payloads, even NTP — but DNS is the most common because it is the most universally allowed. Blocking outbound DNS and forcing all resolution through a monitored internal resolver is one mitigation, but it requires careful planning to avoid breaking legitimate services. If you are investigating a suspected breach and your firewall logs look clean, that is not reassurance. It means you need to look at a different log. DNS query logs, packet captures on port 53, and resolver statistics are where DNS tunneling evidence lives. For related patterns where attacks bypass your logging entirely, see how credential stuffing slips past WAF rules and how data exfiltration happens without a ransom note. Start with DNS query logging. If you are not logging DNS queries today, you have a gap in your visibility that no amount of firewall log review will fill.

Join My Newsletter & Get Updates!

Get notified whenever a new technical guide, server infrastructure breakdown, or personal reflection goes live, plus a curated weekly digest.