Skip to main content

DNS Security and DoH/DoT Complete Guide 2026

Created: March 2, 2026 Larry Qu 12 min read

Introduction

The Domain Name System (DNS) is one of the most fundamental components of the internet. It translates human-readable domain names into IP addresses that computers use to communicate. Despite its critical importance, DNS was designed in 1983 without security considerations.

Today, DNS faces numerous threats: DNS hijacking redirects users to malicious sites, DNS-based malware uses DNS for command and control, DNS tunneling exfiltrates data through DNS queries, and surveillance of DNS traffic reveals browsing activity.

This comprehensive guide explores DNS security in depth: the threats facing DNS, protective technologies including DNS over HTTPS (DoH), DNS over TLS (DoT), and DNSSEC, and implementation strategies for both enterprises and individuals.

Understanding DNS

How DNS Works

DNS operates as a distributed database mapping domain names to IP addresses. When you type “example.com” in your browser, your device queries DNS servers to resolve that domain to an IP address.

The resolution process involves multiple steps:

  1. The operating system checks its local resolver cache for a recent answer
  2. If not found, it queries a recursive resolver (typically provided by your ISP or network)
  3. The recursive resolver traverses the hierarchy: root servers → TLD servers → authoritative name servers
  4. The final answer is cached at every level for the record’s TTL duration

This process happens for every domain lookup, making DNS a critical infrastructure component.

For a deeper understanding of the full resolution chain, see the DNS Deep Dive: Resolution, Records, and Security.

DNS Record Types

Several DNS record types are relevant to security.

A records map domain names to IPv4 addresses. AAAA records map to IPv6 addresses. CNAME records create aliases pointing to other domains. MX records specify mail servers. TXT records hold arbitrary text for various purposes including security verification (SPF, DKIM, DMARC).

Understanding these records helps when investigating DNS-based threats.

Traditional DNS Vulnerabilities

DNS was designed for functionality, not security. Several vulnerabilities exist:

  • Plaintext queries: DNS queries are sent in clear text over UDP port 53. Anyone between your device and the DNS server can see which domains you request.
  • No response verification: DNS responses are not cryptographically signed by default. Attackers can inject fake responses via man-in-the-middle or server impersonation.
  • Cache poisoning: Attackers can inject false records into resolver caches, redirecting traffic without the user’s knowledge.
  • Amplification potential: Small queries generate large responses, making DNS a vector for DDoS amplification attacks.

DNS Security Threats

DNS Hijacking

DNS hijacking redirects DNS queries to attacker-controlled servers. This can occur through compromised routers, malware on endpoints, or attacks on DNS resolvers.

Victims who believe they are visiting legitimate websites are actually connecting to imposters. This enables phishing, malware delivery, and data theft.

DNS Tunneling

DNS tunneling encodes data within DNS queries and responses. Attackers use this technique to exfiltrate data from compromised networks or establish command-and-control channels.

DNS tunneling is particularly insidious because DNS is often allowed through firewalls. Organizations may block HTTP/HTTPS traffic while permitting DNS, creating an exfiltration pathway.

DNS-Based Malware

Malware uses DNS for various malicious purposes. Some malware receives instructions through DNS TXT records. Other malware uses DNS queries to locate command-and-control servers.

Because DNS is essential for network connectivity, blocking DNS breaks legitimate applications. This makes DNS-based threats difficult to mitigate.

DNS Spoofing and Cache Poisoning

DNS spoofing injects false records into DNS resolver caches. Once poisoned, users receive incorrect responses until the cache expires.

This attack can redirect traffic to malicious servers or cause denial of service by providing non-existent addresses.

Privacy Concerns

Even without malicious intent, DNS queries reveal browsing activity. ISPs, network operators, and anyone monitoring network traffic can see which domains users visit.

This privacy concern has driven development of encrypted DNS protocols.

DNS over TLS (DoT)

What Is DoT?

DNS over TLS (DoT) encrypts DNS queries using TLS transport. Rather than sending DNS requests in plaintext over UDP port 53, DoT uses TCP port 853 with TLS encryption.

The encryption prevents eavesdropping on DNS queries. Even if attackers intercept network traffic, they cannot see which domains are being resolved.

How DoT Works

DoT establishes a TLS connection between the client and the DNS resolver. The client validates the resolver’s certificate to prevent man-in-the-middle attacks.

After establishing the TLS tunnel, DNS queries and responses flow through the encrypted channel. The protocol is relatively simple—the same DNS messages are wrapped in TLS.

import socket
import ssl

def query_dns_over_tls(domain, dns_server="8.8.8.8"):
    """Query DNS over TLS."""
    context = ssl.create_default_context()
    
    with socket.create_connection((dns_server, 853)) as sock:
        with context.wrap_socket(sock, server_hostname=dns_server) as ssock:
            transaction_id = b'\x00\x01'
            flags = b'\x01\x00'
            questions = b'\x00\x01'
            answer_rrs = b'\x00\x00'
            authority_rrs = b'\x00\x00'
            additional_rrs = b'\x00\x00'
            
            domain_parts = domain.split('.')
            query = transaction_id + flags + questions + answer_rrs + authority_rrs + additional_rrs
            for part in domain_parts:
                query += bytes([len(part)]) + part.encode()
            query += b'\x00'
            query += b'\x00\x01'
            query += b'\x00\x01'
            
            length = len(query).to_bytes(2, 'big')
            ssock.send(length + query)
            
            length_bytes = ssock.recv(2)
            response_length = int.from_bytes(length_bytes, 'big')
            response = ssock.recv(response_length)
            return response

DoT Advantages

DoT provides encryption for DNS queries, protecting privacy from passive network surveillance. It is standardized (RFC 7858), supported by Android and recent iOS versions, and straightforward to implement for organizations that control their DNS infrastructure. The dedicated port (853) makes DoT traffic easy to monitor and whitelist for security teams.

DoT Limitations

DoT uses a dedicated port (853) that can be blocked by restrictive firewalls. Some networks (public Wi-Fi, hotel networks, corporate proxies) only permit outbound HTTP/HTTPS on ports 80 and 443. DoT provides encryption but does not validate DNS response authenticity—DNSSEC is still required for that.

DNS over HTTPS (DoH)

What Is DoH?

DNS over HTTPS (DoH) encrypts DNS queries by transmitting them over HTTPS. DNS queries become HTTP requests to special DoH endpoints.

DoH uses port 443, the same port as regular HTTPS traffic. This makes DoH traffic indistinguishable from normal web traffic, providing both encryption and privacy from network observers.

How DoH Works

DoH encodes DNS queries as HTTP GET requests. The domain to resolve is encoded in a JSON payload or as a path parameter.

The DoH server responds with DNS data encoded in JSON or application/dns-message format. Both request and response are encrypted within the HTTPS connection.

import requests

def query_dns_over_https(domain, doh_server="https://cloudflare-dns.com/dns-query"):
    """Query DNS over HTTPS."""
    headers = {
        'accept': 'application/dns-json'
    }
    
    params = {
        'name': domain,
        'type': 'A'
    }
    
    response = requests.get(doh_server, headers=headers, params=params)
    return response.json()

DoH Advantages

DoH provides strong encryption and privacy. Network observers cannot distinguish DNS queries from other HTTPS traffic. DoH is harder to block than DoT because it uses standard HTTPS port 443—firewalls that permit web browsing cannot selectively block DoH. Major browsers (Chrome, Firefox, Edge) support DoH natively, enabling widespread deployment. Cloudflare (1.1.1.1), Google (8.8.8.8), and Quad9 offer public DoH services.

DoH Limitations

DoH can interfere with enterprise security monitoring. Security tools that inspect DNS traffic (firewalls, DNS filters, SIEM integrations) lose visibility when clients bypass internal resolvers. Browser-based DoH in particular can circumvent corporate DNS filtering policies. DoH adds slight latency from HTTPS overhead and JSON parsing, though the impact is minimal for most applications.

DoH vs DoT Comparison

flowchart LR
    subgraph Client["Client"]
        B[Browser]
        OS[OS Resolver]
    end
    subgraph Network["Network Path"]
        FW[Firewall]
    end
    subgraph Resolver["DNS Resolver"]
        DOT[DoT :853]
        DOH[DoH :443]
    end

    B -->|DoH| FW
    OS -->|DoT| FW
    FW -->|port 443 visible| DOH
    FW -->|port 853 visible or blocked| DOT
Feature DoT DoH
Port 853 443
Traffic Appearance Distinct TLS on port 853 Standard HTTPS on port 443
Firewall Friendly Moderate — port 853 can be blocked High — indistinguishable from web traffic
Privacy High — encrypted but identifiable as DNS Very High — looks like any HTTPS request
Standardization RFC 7858 RFC 8484
OS Support Android 9+, iOS 14+ Windows 10+, macOS, all major browsers
Network Monitoring Easier — known port and protocol Harder — mixes with web traffic
Debugging Straightforward with tcpdump Requires HTTP-level inspection

When to Use Each

DoT is appropriate when you control both client and resolver, you need simpler implementation, or security monitoring requires clear DNS traffic visibility.

DoH is appropriate when privacy is paramount, you need to work around restrictive firewalls that block non-standard ports, or you want browser-based deployment without OS-level configuration.

Many organizations implement both, supporting DoH for browsers and DoT for other applications. For the emerging standard that combines the best of both, see the DNS over QUIC (DoQ) Guide.

DNSSEC

What Is DNSSEC?

DNS Security Extensions (DNSSEC) add cryptographic signatures to DNS data. Rather than encrypting queries, DNSSEC validates that responses originate from authoritative sources and have not been tampered with.

DNSSEC addresses different threats than DoH/DoT. While DoH/DoT protect query privacy, DNSSEC ensures response authenticity.

How DNSSEC Works

DNSSEC uses public key cryptography to sign DNS records. Authoritative DNS servers sign their zones with private keys. Resolvers validate signatures using public keys published in DNS.

The validation chain includes: zone signing keys (ZSK) for regular records, key signing keys (KSK) for signing ZSKs, and trust anchors for root zone.

When DNSSEC is enabled, resolvers validate responses before returning them to clients. Invalid responses are discarded.

DNSSEC Deployment

DNSSEC requires deployment throughout the DNS chain: authoritative servers must sign zones, recursive resolvers must validate signatures, and clients must support DNSSEC validation.

Root zone signing began in 2010. Most top-level domains are now signed. Many authoritative DNS providers support DNSSEC signing.

Client support varies. Android has built-in DNSSEC validation. iOS and macOS have limited support. Browser support is minimal.

DNSSEC Limitations

DNSSEC does not provide encryption—DNS data is still visible on the wire. It only validates authenticity. Deployment complexity has slowed adoption; the validation chain requires coordination across the entire DNS ecosystem. Some middleboxes and enterprise proxies interfere with DNSSEC, causing resolution failures.

DNS-Based Threat Protection

DNS Firewall

DNS firewalls intercept malicious DNS queries and return safe responses (NXDOMAIN or block page). This approach blocks malware at the DNS layer, before it can connect to command-and-control servers, without requiring endpoint agents.

DNS Security Services

Cloud-based DNS security services provide threat intelligence and filtering. These services resolve DNS queries while checking against threat databases updated in real time.

Popular services include:

  • Cisco Umbrella (OpenDNS): Enterprise-grade threat intelligence with global coverage
  • Cloudflare Gateway: Integrated with Zero Trust platform
  • Quad9: Security-focused, non-logging public resolver using multiple threat feeds
  • Google Public DNS: Security filtering option available

These services combine DoH/DoT with threat intelligence, providing both privacy and security.

DNS DDoS Amplification

Attackers can abuse open DNS resolvers to amplify DDoS traffic. A 60-byte query can generate a 4000-byte response—a 66x amplification factor. Mitigation includes:

  • Rate-limiting per source IP on resolvers
  • Response rate limiting (RRL) on authoritative servers
  • Blocking amplification-capable record types (ANY, DNSSEC) from unknown sources

For broader context on network threat mitigation, see the Network Security Best Practices Guide.

Implementation Strategies

For Individuals

Individual users can implement DNS security through several approaches:

  • Enable DoH or DoT in your operating system (Windows: Settings → Network → DNS; Android: Private DNS mode; macOS: Network preferences)
  • Use browsers with DoH support (Chrome, Firefox, Edge) and configure a preferred DoH provider
  • Choose a privacy-respecting provider (Cloudflare, Quad9) with a clear no-logging policy
  • Verify your configuration using tools like dnsleaktest.com or cloudflare.com/ssl/encrypted-snapshot
# Test DoH configuration from command line
curl -s "https://cloudflare-dns.com/dns-query?name=example.com&type=A" \
  -H "accept: application/dns-json" | jq .

For Enterprises

Enterprise implementation requires more planning:

  • Audit current DNS flows: Triage all DNS query sources—endpoints, servers, cloud workloads, guest networks. Each may need different policies.
  • Deploy internal encrypted DNS: Stand up a recursive resolver (Unbound, Knot Resolver) with DoT/DoH listener for internal clients
  • Manage browser DoH: Use Group Policy or MDM to enforce corporate DoH configuration, preventing users from bypassing security controls via browser settings
  • Maintain DNS visibility: Forward logs from your resolver to a SIEM. Ensure firewall and IDS/IPS can inspect DNS traffic from managed resolvers even when traffic is encrypted
  • Segment DNS resolution: Keep internal DNS (RFC 1918) separate from external resolution to avoid data leakage
# Unbound configuration with DoT
server:
    interface: 0.0.0.0
    port: 53
    do-tls: yes
    tls-service-key: /etc/unbound/keys/server.key
    tls-service-pem: /etc/unbound/keys/server.pem
    access-control: 10.0.0.0/8 allow
    access-control: 172.16.0.0/12 allow
    access-control: 192.168.0.0/16 allow

forward-zone:
    name: "."
    forward-tls-upstream: yes
    forward-addr: 1.1.1.1@853#cloudflare-dns.com
    forward-addr: 8.8.8.8@853#dns.google

For comprehensive network troubleshooting that includes DNS diagnostics, see the Network Troubleshooting Complete Guide.

Best Practices

Enable Encryption

Enable DoH or DoT wherever possible. This protects DNS queries from eavesdropping and manipulation. Configure devices and browsers to use encrypted DNS.

Validate Responses

Enable DNSSEC validation where supported. This ensures DNS responses are authentic. Keep systems updated to maintain DNSSEC validation capabilities.

Monitor DNS Traffic

Even with encrypted DNS, monitor for anomalies at your DNS resolvers. Look for unusual query patterns that may indicate compromise. Implement logging and alerting for DNS-related security events.

Use Secure Providers

Choose DNS providers with strong privacy policies. Understand what data they collect and how they use it. Consider providers that do not log queries or have been independently audited.

Implement Defense in Depth

DNS security is one layer. Combine encrypted DNS with other security controls: endpoint protection, network security, and user training. No single control provides complete protection.

Challenges and Considerations

Performance Impact

Encrypted DNS adds latency compared to plaintext DNS. The overhead includes TLS handshake, potentially longer resolution times. For most users, this impact is minimal. Performance-critical applications may require connection reuse or pre-warmed TLS sessions.

Compatibility Issues

Some networks and applications do not support encrypted DNS. Network administrators may block DoT port 853. Test deployments thoroughly to ensure functionality across all environments.

Privacy Tradeoffs

Encrypted DNS shifts trust from network operators to DNS providers. Your DNS provider sees your full query history. Evaluate providers carefully and understand their privacy practices. Consider running your own recursive resolver for maximum control.

Operational Complexity

Enterprise DNS security implementation adds complexity. Multiple systems, policies, and monitoring tools must work together. Plan for training and ongoing management.

The Future of DNS Security

Encrypted DNS Adoption

Encrypted DNS adoption is accelerating. Major browsers and operating systems are enabling it by default. This trend will continue as privacy concerns grow and encryption becomes standard.

Post-Quantum DNS

As quantum computing advances, current cryptographic methods may become vulnerable. Research into post-quantum DNS security is beginning. Standards development will address these future threats.

DNS Privacy Regulations

Regulations may address DNS privacy. Current approaches vary by jurisdiction. Organizations should monitor regulatory developments that may affect DNS implementations.

Integrated Security

DNS security will increasingly integrate with broader security platforms. DNS as a security service will provide more comprehensive protection. The boundary between DNS resolution and security will continue to blur.

Conclusion

DNS security is essential for protecting privacy and preventing attacks. The combination of encrypted DNS (DoH/DoT), DNSSEC validation, and DNS-based threat protection provides comprehensive defense.

Individual users should enable encrypted DNS in their devices and browsers. Organizations should implement DNS security as part of a defense-in-depth strategy.

The transition from plaintext DNS to encrypted DNS is underway. As adoption accelerates, the internet becomes more private and secure.

Understanding DNS security options and implementing appropriate protections is a fundamental step in securing your digital presence.

Resources

Comments

Share this article

Scan to read on mobile

👍 Was this article helpful?