乐闻世界logo
搜索文章和话题

What Are the Differences Between DNS over HTTPS (DoH) and DNS over TLS (DoT)

3月7日 12:07

DoH and DoT Overview

DNS over HTTPS (DoH) and DNS over TLS (DoT) are encrypted DNS protocols designed to solve the security problems of traditional DNS. They encrypt DNS queries and responses to prevent man-in-the-middle attacks, eavesdropping, and DNS hijacking.

Why Encrypted DNS is Needed

Security Issues with Traditional DNS

shell
┌─────────┐ Plaintext UDP 53 ┌─────────┐ │ Client │ ◄───────────────────────► │ DNS Server│ └─────────┘ └─────────┘ ↑ Man-in-the-middle can eavesdrop and tamper

Risks:

  • DNS queries are eavesdropped, exposing websites users visit
  • DNS responses are tampered, leading to phishing sites
  • ISPs can record and analyze users' DNS queries

DNS over TLS (DoT)

How It Works

DoT uses the TLS protocol to encrypt DNS queries, adding a TLS encryption layer on top of the standard DNS protocol.

shell
┌─────────┐ TLS Encrypted Tunnel ┌─────────┐ │ Client │ ◄────────────────────────────► │ DoT Server│ │ │ Port 853 │ │ └─────────┘ └─────────┘

Protocol Stack:

shell
Application Layer: DNS Query/Response Transport Layer: TLS Encryption Network Layer: TCP

Technical Characteristics

FeatureDescription
Transport ProtocolTCP
Port853 (Dedicated Port)
Encryption MethodTLS 1.2 or TLS 1.3
Certificate VerificationRequires server certificate verification

Communication Flow

shell
1. Client establishes TCP connection with DoT server (port 853) 2. TLS handshake, negotiate encryption parameters 3. Verify server certificate 4. Send DNS query through encrypted tunnel 5. Receive encrypted DNS response

Configuration Example

systemd-resolved Configuration:

ini
[Resolve] DNS=8.8.8.8 8.8.4.4 DNSOverTLS=yes

Android Configuration (Private DNS):

shell
Private DNS provider hostname: dns.google

DNS over HTTPS (DoH)

How It Works

DoH encapsulates DNS queries in HTTPS requests, using standard HTTP/2 protocol for transmission.

shell
┌─────────┐ HTTPS Request/Response ┌─────────┐ │ Client │ ◄────────────────────────────► │ DoH Server│ │ │ Port 443 │ │ └─────────┘ └─────────┘

Protocol Stack:

shell
Application Layer: DNS Message (encapsulated in HTTP body) Transport Layer: HTTP/2 Security Layer: TLS 1.2/1.3 Network Layer: TCP

Technical Characteristics

FeatureDescription
Transport ProtocolHTTP/2 over TLS
Port443 (Same as HTTPS)
Request MethodGET or POST
Content Typeapplication/dns-message

Communication Flow

shell
1. Client establishes HTTPS connection with DoH server (port 443) 2. Encode DNS query as DNS message format 3. Send request via HTTP POST or GET 4. Server returns HTTP response containing DNS response 5. Client parses DNS response from HTTP body

Request Example

POST Request:

http
POST /dns-query HTTP/1.1 Host: cloudflare-dns.com Content-Type: application/dns-message Content-Length: 33 <binary DNS query message>

Response:

http
HTTP/1.1 200 OK Content-Type: application/dns-message Content-Length: 65 <binary DNS response message>

Configuration Example

Firefox Configuration:

shell
about:config network.trr.mode = 2 network.trr.uri = https://cloudflare-dns.com/dns-query

Chrome Configuration:

shell
Settings → Privacy and Security → Security → Use secure DNS Select: Cloudflare (1.1.1.1)

DoH vs DoT Detailed Comparison

Comparison ItemDoTDoH
Protocol LayerTransport Layer (TLS)Application Layer (HTTPS)
Port853 (Dedicated)443 (Shared with HTTPS)
Traffic CharacteristicsEasily identified as DNS trafficMixed with normal HTTPS traffic
Deployment DifficultySimplerRequires HTTP server support
PerformanceSlightly better (less protocol overhead)Slightly worse (HTTP overhead)
Firewall PenetrationMay be blocked by enterprise firewallsDifficult to block (same as HTTPS)
LoggingDedicated DNS logsMixed in Web access logs

Pros and Cons of Each

DoT Advantages

Simple Protocol: Directly adds TLS layer on DNS ✅ Better Performance: Less protocol overhead, lower latency ✅ Dedicated Port: Clear traffic separation ✅ Easy to Monitor: Network administrators can distinguish DNS traffic

DoT Disadvantages

Easily Identified: Dedicated port 853 easily blocked by firewalls ❌ Less Privacy: ISPs can know you're using encrypted DNS ❌ Restricted in Enterprise: May be blocked by enterprise security policies

DoH Advantages

High Stealth: Traffic indistinguishable from normal HTTPS ✅ Firewall Friendly: Port 443 usually open ✅ Easy to Deploy: Reuses existing Web infrastructure ✅ Privacy Protection: ISPs cannot distinguish DNS queries from Web access

DoH Disadvantages

Complex Protocol: Requires HTTP/2 protocol stack ❌ Performance Overhead: HTTP headers add extra overhead ❌ Hard to Monitor: Enterprise network administrators cannot audit DNS queries ❌ Mixed Logs: DNS logs mixed with Web logs

Major DoH/DoT Service Providers

ProviderDoH AddressDoT AddressFeatures
Cloudflarehttps://cloudflare-dns.com/dns-query1.1.1.1:853Fast, privacy-first
Googlehttps://dns.google/dns-query8.8.8.8:853Stable and reliable
Quad9https://dns.quad9.net/dns-query9.9.9.9:853Malicious domain blocking
Alibabahttps://dns.alidns.com/dns-query223.5.5.5:853Fast domestic access
DNSPodhttps://doh.pub/dns-query-Tencent subsidiary

How to Choose Between DoH and DoT

Scenarios for Choosing DoT

  • Enterprise network environments requiring DNS traffic monitoring
  • Pursuing best performance, reducing protocol overhead
  • Network administrators need to audit DNS queries
  • Firewall policies allow port 853

Scenarios for Choosing DoH

  • Public WiFi and other untrusted networks
  • Need to bypass DNS censorship or hijacking
  • Pursuing highest privacy protection
  • Enterprise firewalls block port 853

Practical Recommendations

shell
Individual users (privacy priority): DoH Enterprise users (management needs): DoT Mobile devices (variable networks): DoH Server environments (performance priority): DoT

Common Interview Questions

Q: What's the difference between DoH and HTTPS?

A: DoH uses HTTPS as the transport layer to transmit DNS messages. Regular HTTPS transmits Web content (HTML, JS, etc.), while DoH transmits DNS queries and response messages (binary format).

Q: Why is DoH harder to block by firewalls than DoT?

A: Because DoH uses standard HTTPS port 443, traffic characteristics are identical to normal Web access. DoT uses dedicated port 853, which is easily identified and blocked.

Q: Can DoH/DoT completely prevent DNS hijacking?

A: They can prevent hijacking and eavesdropping during transmission, but cannot prevent:

  • Client configuration tampered by malware
  • DoH/DoT server itself being attacked
  • Local hosts file being modified

Summary

AspectDoTDoH
Core ProtocolTLSHTTPS
Best ScenarioEnterprise networks, performance priorityPrivacy protection, bypass censorship
Deployment DifficultyLowMedium
Privacy ProtectionGoodExcellent
PerformanceExcellentGood
Firewall PenetrationPoorExcellent

Trend: Currently DoH is more favored by browser vendors (Firefox, Chrome default support), while DoT is more supported by system-level and network device vendors. Both are effective solutions for encrypted DNS, and the choice depends on specific scenario requirements.

标签:DNS