0Pricing
Cloud & IT Cert Prep · Lesson

Secure DNS: DNSSEC and DNS over HTTPS (DoH)

Learn how DNSSEC prevents DNS cache poisoning and how DNS over HTTPS and DNS over TLS protect query privacy against on-path observers.

Secure DNS: DNSSEC and DNS over HTTPS (DoH) is a free Cloud & IT Cert Prep lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Cloud & IT Cert Prep learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

DNS Security Challenges

The Domain Name System (DNS) translates human-readable domain names into IP addresses. Designed in the 1980s, DNS was built without security — queries and responses travel over UDP/TCP port 53 in plaintext with no authentication. This creates two major vulnerabilities: DNS cache poisoning (injecting forged DNS responses to redirect users to malicious servers) and DNS eavesdropping (observing which domains a user queries reveals their browsing activity). Two standards address these: DNSSEC prevents forgery, and DNS over HTTPS (DoH) prevents eavesdropping.

DNS Cache Poisoning

DNS cache poisoning (Kaminsky attack) exploits the DNS protocol's lack of authentication. A resolver sends a query to an authoritative DNS server and caches the response for the TTL duration. An attacker who can guess the transaction ID (16-bit, predictable) and source port (used as additional entropy since RFC 5452) can send forged responses that the resolver caches, redirecting all users who query that resolver to the attacker's server. Once the cache is poisoned, users are directed to fake servers even though they typed the correct domain. DNSSEC prevents this by digitally signing DNS responses.

# DNS cache poisoning simulation
# Attacker floods resolver with forged responses
# for the query 'A example.com?'

# Each response guesses a different transaction ID:
# ID=1234: example.com -> 198.51.100.1  (attacker IP)
# ID=1235: example.com -> 198.51.100.1
# ...
# ID=XXXX: example.com -> 198.51.100.1  (correct guess!)

# Resolver caches poisoned answer (TTL = 3600s)
# All users querying this resolver get attacker IP
# Users are redirected to phishing/malware server

DNSSEC: DNS Security Extensions

DNSSEC adds cryptographic signatures to DNS records, allowing resolvers to verify that responses came from the legitimate zone authority and have not been tampered with. DNSSEC introduces new record types: RRSIG (resource record signature, the actual signature over a record set), DNSKEY (the public key used to verify signatures), DS (delegation signer, links parent and child zone keys), and NSEC/NSEC3 (authenticated denial of existence — proves a name does not exist). DNSSEC creates a chain of trust from the root zone (signed by ICANN) down through TLD and authoritative zones.

# Verify DNSSEC signature on a domain
dig +dnssec example.com A
# Look for 'ad' (authenticated data) flag in response
# and the RRSIG record alongside the A record

# Query for DNSKEY record
dig DNSKEY example.com

# Query for DS record at parent zone
dig DS example.com @a.iana-servers.net

# Full DNSSEC chain validation check
dig +sigchase +trusted-key=/.../root.key example.com A

DNSSEC Key Types: KSK and ZSK

DNSSEC uses two types of signing keys. The Zone Signing Key (ZSK) signs the individual DNS record sets (RRSIGs) and is rotated frequently (monthly or quarterly) for operational agility. The Key Signing Key (KSK) signs the DNSKEY record set, providing the anchor of trust for the zone. The KSK is rotated less frequently (annually) because the parent zone must be updated with the new DS record whenever the KSK changes — a process requiring coordination. The KSK verifies the ZSK; the ZSK signs the data. This two-layer structure balances security (frequent ZSK rotation) against operational burden (infrequent KSK rotation).

DNSSEC Limitations

DNSSEC has important limitations. It does not encrypt DNS queries — it only signs responses for integrity. An eavesdropper can still see all DNS queries, just cannot forge responses. Zone enumeration: NSEC records (which prove non-existence) allow attackers to walk the zone and enumerate all domain names within it; NSEC3 mitigates this with hashed names but is not perfect. Operational complexity: key management, signature expiry, and parent zone coordination create significant operational overhead. DNSSEC adoption remains incomplete — many TLDs and registrars support it, but many organizations have not deployed it.

DNS over HTTPS (DoH)

DNS over HTTPS (DoH) encrypts DNS queries inside HTTPS (RFC 8484), hiding query contents from network observers. Queries go to a DoH-capable resolver at a standard HTTPS URL, making DNS traffic indistinguishable from other HTTPS traffic. This prevents ISPs, employers, and on-path attackers from seeing which domains a user queries — addressing the privacy gap that DNSSEC leaves. However, DoH shifts trust from the network's DNS resolver to the DoH provider (typically Google 8.8.8.8, Cloudflare 1.1.1.1, or the organization's own DoH resolver). DoH is now supported natively in most major browsers.

# DoH query using curl
curl -H 'accept: application/dns-json' \
  'https://cloudflare-dns.com/dns-query?name=example.com&type=A'

# DoH query via RFC 8484 (binary format)
curl -s -H 'Content-Type: application/dns-message' \
     -H 'Accept: application/dns-message' \
     --data-binary @query.bin \
     https://dns.google/dns-query

# Configure Firefox to use DoH
# about:config -> network.trr.uri
# Set to: https://mozilla.cloudflare-dns.com/dns-query

DNS over TLS (DoT)

DNS over TLS (DoT) (RFC 7858) encrypts DNS queries using TLS over a dedicated TCP port 853, rather than tunneling through HTTPS. DoT provides the same privacy benefits as DoH — hiding query content from eavesdroppers — but is easier for network administrators to identify and filter (port 853 vs port 443). This is a double-edged sword: DoT is visible and can be blocked by enterprise firewalls, whereas DoH is harder to block without affecting general HTTPS traffic. Stub resolvers (OS-level) more commonly use DoT; browsers more commonly use DoH.

# Test DoT connection using kdig
kdig -d @9.9.9.9 +tls-ca example.com A

# Test DoT using openssl
openssl s_client -connect 1.1.1.1:853
# Then type: query string in DNS wire format

# Configure systemd-resolved to use DoT (Linux)
# /etc/systemd/resolved.conf:
[Resolve]
DNS=9.9.9.9#dns.quad9.net
DNSOverTLS=yes

DoH and DoT: Enterprise Considerations

Encrypted DNS creates a challenge for enterprise environments that depend on DNS-based filtering and sinkholes. When browsers use external DoH resolvers, internal DNS controls are bypassed. Enterprise countermeasures: deploy an internal DoH/DoT resolver (Cisco Umbrella, Pi-hole with DoH) and configure all devices to use it; block external DoH resolver IPs at the firewall (Google 8.8.8.8, Cloudflare 1.1.1.1) on port 443; Group Policy to disable browser-level DoH on managed endpoints; and transparent proxy rules that intercept DNS-over-TLS on port 853. The goal: route all DNS through the controlled resolver without blocking encrypted DNS entirely.

# Enterprise DoH bypass prevention
# Windows Group Policy:
# Computer Config > Admin Templates > Google Chrome
# 'DNS over HTTPS mode': Disabled
# 'DNS over HTTPS URI templates': <empty>

# Firewall: block known public DoH resolvers
iptables -I FORWARD -d 8.8.8.8 -p tcp --dport 443 -j DROP
iptables -I FORWARD -d 1.1.1.1 -p tcp --dport 443 -j DROP
iptables -I FORWARD -d 9.9.9.9 -p tcp --dport 443 -j DROP
iptables -I FORWARD -d 149.112.112.112 -p tcp --dport 443 -j DROP

# Redirect all DNS to corporate resolver
iptables -t nat -A PREROUTING -p udp --dport 53 \
  -j DNAT --to-destination 10.0.0.53:53

DNS Security in Practice

A complete DNS security strategy combines multiple controls. DNSSEC for your authoritative zones prevents cache poisoning of your domain. DNS-based filtering (Cisco Umbrella, Cloudflare Gateway) blocks malicious domains at the resolver level. DoH/DoT to a controlled resolver provides query privacy without losing filtering visibility. DNS logging to the SIEM captures all queries for threat hunting — DNS logs reveal C2 traffic, data exfiltration via DNS tunneling, and domain generation algorithm (DGA) activity from malware. DNS telemetry is one of the highest-value security data sources available.

DNS Tunneling Detection

DNS tunneling encodes data inside DNS queries and responses to exfiltrate data or establish C2 channels through networks where other outbound traffic is blocked. Tools like iodine, DNScat, and dnscat2 encode payloads in subdomain labels (query for EXFILTRATEDDATA.evil.com) or TXT records. Detection: unusually long DNS query names (>100 characters), high query volume from a single host, queries for non-existent parent domains, unusual record types (TXT, NULL), and entropy analysis of domain labels (encoded data has high Shannon entropy). DNS security analytics platforms automatically flag tunneling patterns.

# DNS tunneling detection indicators
# Flag queries with:
# 1. Query name > 100 characters
# 2. More than 50 queries/minute from single host
# 3. High-entropy domain labels (base64/hex patterns)
# 4. TXT or NULL record type queries (unusual)
# 5. Queries to domains with no web presence

# Example tunnel query (encoded payload)
# aGVsbG8gd29ybGQ.vGhpcyBpcyBkYXRh.evil-domain.com
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# Base64 encoded 'hello world this is data'

DNS Response Policy Zones (RPZ)

DNS Response Policy Zones (RPZ) allow DNS resolvers to apply local override policies to DNS responses — essentially creating a local sinkhole at the resolver level without modifying global DNS infrastructure. When a client queries for a known-malicious domain, the RPZ policy returns NXDOMAIN, a redirect to a sinkhole IP, or a passthrough response. RPZ feeds are available from threat intelligence providers (Spamhaus, SURBL) and can be imported directly into BIND or Unbound resolvers. RPZ is a powerful defensive tool because it applies filtering at the DNS layer for all devices on the network without any client-side configuration.

# BIND RPZ configuration snippet
# /etc/named.conf
response-policy {
  zone 'rpz.spamhaus.net';
  zone 'local-blocklist.internal';
};

# RPZ zone file (local-blocklist.internal)
$ORIGIN local-blocklist.internal.
@  SOA  ns1.company.com. admin.company.com. 2024010101 3600 600 86400 300
botnet-c2.evil IN CNAME .   # NXDOMAIN response
phishing-site.com IN A 10.0.0.99  # Redirect to sinkhole

Quick Check

Test your understanding of CompTIA Security+ (SY0-701) concepts from this lesson.

Lesson Recap

In this lesson you learned: DNSSEC adds cryptographic signatures to DNS records using KSK/ZSK key pairs to prevent cache poisoning but does not encrypt queries, DNS over HTTPS (DoH) encrypts DNS queries inside HTTPS to prevent eavesdropping but creates enterprise filtering bypass risks, and DNS tunneling encodes data in DNS queries and can be detected through query length, volume, and entropy analysis. Next up we explore IPsec, VPN protocols, and remote access security.

Frequently asked questions

Is the “Secure DNS: DNSSEC and DNS over HTTPS (DoH)” lesson free?

Yes — the full text of “Secure DNS: DNSSEC and DNS over HTTPS (DoH)” is free to read here on the web, and the Cloud & IT Cert Prep course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Cloud & IT Cert Prep course, upgrade to CoddyKit PRO.

What will I learn in “Secure DNS: DNSSEC and DNS over HTTPS (DoH)”?

Learn how DNSSEC prevents DNS cache poisoning and how DNS over HTTPS and DNS over TLS protect query privacy against on-path observers. You practise Cloud & IT Cert Prep with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Cloud & IT Cert Prep?

No prior experience is required. Cloud & IT Cert Prep on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Secure DNS: DNSSEC and DNS over HTTPS (DoH)” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Cloud & IT Cert Prep lesson?

Yes. Every Cloud & IT Cert Prep lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Replacing Insecure Protocols: Telnet vs SSH, FTP vs SFTP
  2. TLS Versions, Cipher Suites, and Perfect Forward Secrecy
  3. Secure DNS: DNSSEC and DNS over HTTPS (DoH)
  4. IPsec, VPN Protocols, and Remote Access Security
← Back to Cloud & IT Cert Prep