7 min read
November 13, 2023

What is DNS Tunneling? How Can You Prevent DNS Tunneling Attacks?

Security has become a massive concern in the rapidly evolving world of information technology. Our ever-increasing reliance on digital systems means the threats we face are becoming more sophisticated.  

One such threat is DNS tunnelling, a technique that can be used to bypass network security measures and carry out malicious activities such as DNS data infiltration and DNS-based malware distribution. This article will provide you with an understanding of DNS tunnelling, its risks, and how to prevent them.

What is DNS Tunnelling?

DNS, or Domain Name System, is a protocol that translates human readable domain names (for example, to machine readable IP addresses (for example,

DNS tunnelling is a method used to encode the data of other programs or protocols in DNS queries and responses. It leverages this system to smuggle data in and out of a network, making it an example of DNS exfiltration and DNS command and control technique.  

DNS tunnelling has existed for almost 20 years and is not inherently malicious. Initially designed to encapsulate network traffic, it can be used for legitimate purposes such as bypassing firewalls and other network restrictions to access blocked content.  

However, cybercriminals have exploited this technique for nefarious purposes, such as data exfiltration, C&C (command and control), and DNS-based malware distribution.

How does DNS Tunnelling work?  

DNS tunnelling exploits the structure of the DNS protocol by using DNS encoders to encode the data or command and carry out attacks.  

Here's a simplified step-by-step explanation:  

  1. The attacker sets up a server that hosts malware, with a specific domain pointing to that server.  
  1. The attacker infects a device with DNS-based malware, which then makes a DNS request to the attacker-controlled domain.  
  1. As the DNS resolver processes the request, it inadvertently creates a 'tunnel' between the attacker and the infected device. This tunnel can be used for data exfiltration or other malicious activities.  
  1. The data or command the attacker wants to send is encoded into the subdomains of the DNS query.  
  1. When the DNS server receives the query, it decodes the subdomains to retrieve the hidden data or command. This allows the data to be transferred even if the network's security measures typically block it.  
  1. Because the connection is indirect (going through the DNS server rather than directly from the attacker to the victim), it's more challenging to trace it back to the attacker's computer. This makes DNS tunnelling a stealthy technique for carrying out cyber-attacks.

What are the risks of DNS Tunnelling?

The primary risk of DNS tunnelling is that it can be used to bypass network security measures. Since DNS is a necessary protocol for the functioning of the internet, most networks allow DNS traffic to pass through without inspection. This makes DNS an ideal channel for cybercriminals to data exfiltration, network infiltration or control of DNS tunnelling malware.

DNS tunnelling can also be used to carry out attacks, where a large amount of DNS traffic is used to overwhelm a network and cause a denial of service.  

Furthermore, DNS tunnelling can be used to hide the presence of DNS-based malware on a network, making it harder to detect and remove.

How can DNS Tunnelling risks be prevented?

Preventing DNS tunnelling risks involves a combination of monitoring, detection, and mitigation strategies.  

Monitoring involves keeping a close eye on DNS traffic to identify any unusual patterns or volumes and DNS tunnelling tools like dnsHunter and reassemble_dns can be used.  

Detection involves using DNS tunnelling tools and techniques to identify this type of activity. This can include looking for anomalies in DNS requests, such as unusually long domain names or a high frequency of requests.

Mitigation of DNS tunnelling attacks involves proactive measures once the activity has been detected. This defence can take various forms. For instance, one could block domain names, IP addresses, or geolocation regions based on their known reputation or perceived danger. In addition, implementing rules around peculiar DNS query strings or the length, type, or size of both outbound and inbound DNS queries can also be effective.

What is Ultra-slow DNS Tunnelling and how can it be prevented?

Ultra-slow DNS tunnelling is a more covert attempt at circumventing network security measures in which data is transferred in small chunks and at a very low rate. This is typically achieved by spreading DNS queries across multiple domains and defining very low Time-to-Live (TTL) values for them to reduce the likelihood of detection.

Since data is transmitted in small amounts over a long period of time, it is essential to implement powerful DNS monitoring tools capable of discovering suspicious DNS traffic patterns such as unusual query sizes or frequent queries to the same domain.

Best practices for DNS Security

Implementing best practices for DNS security can help to prevent DNS tunnelling vulnerabilities.  

These include:

  • Regularly updating and patching DNS servers to protect against known vulnerabilities.
  • Implementing DNSSEC (DNS Security Extensions) to verify the authenticity of DNS responses.
  • Using a DNS firewall to block malicious domains.
  • Implementing rate limiting to prevent DNS tunnelling attacks.
  • Regularly monitoring and auditing DNS logs to detect any unusual activity.

How does DNSSense solve the problem?

DNSSense offers a solution called DNSDome, a comprehensive cloud-based protection system that defends networks against advanced threats.  

Powered by AI-based threat intelligence Cyber X-Ray, DNSDome uses heuristics and behavioural methods to detect and block DNS tunnelling attempts instantly. It provides enhanced protection against sophisticated attacks such as ultra-slow DNS tunnelling by its uncanny ability to identify and block data packets as small as 1.5 MB transferred over a period of 2 years.  

This solution is particularly effective as many organisations do not examine their DNS traffic for malicious activity, making DNS Tunnelling a powerful tool in the arsenal of threat actors to bypass defences.


DNS tunnelling is a serious security threat that can be used to bypass network security measures and carry out malicious activities. However, with the proper knowledge and tools, detecting and preventing DNS tunnelling is possible.

By implementing best practices for DNS security and using advanced solutions like DNSSense's DNSDome, organisations can protect their networks and ensure their data remains secure.

Visit: Prevent DNS Tunnelling Attacks

Frequently Asked Questions

What are the advantages and limitations of DNS exfiltration/low-and-slow data leakage techniques?

What are some commonly used DNS tunnels/protocols?

How can DNS tunnelling be detected in encrypted traffic?

What are the best practices for mitigation of DNS tunnelling malware in enterprise environments?

How can steganographic DNS tunnelling attacks be prevented?

What are the implications of DNS-based command and control channels used by advanced persistent threat (APT) groups?

What are the latest trends in DNS tunnelling techniques and how can they be countered?

How do DNS tunnelling attacks impact network performance and what are the most effective ways to prevent them?