🌍 Networking

DNS over HTTPS

A protocol that encrypts DNS queries over HTTPS

📖 Detailed Explanation

DNS over HTTPS (DoH) is a security protocol that encrypts DNS queries and transmits them over the HTTPS protocol. Because traditional DNS sends queries in plaintext, ISPs and network administrators could eavesdrop on which websites users were visiting. DoH solves this problem and ensures DNS privacy.

DoH was standardized as RFC 8484 in 2018, and Cloudflare and Google were early adopters. Because it uses HTTPS port 443, it cannot be distinguished from regular web traffic, so it can bypass censorship. Firefox enabled DoH by default in the United States starting in 2020, and major browsers such as Chrome, Edge, and Safari also support it.

A protocol similar to DoH is DoT (DNS over TLS). DoT uses port 853, and thanks to the dedicated port, network administrators can manage DNS traffic separately. DoH, on the other hand, is mixed in with web traffic and is difficult to block. DoT is preferred in enterprise environments, and DoH is preferred where personal privacy is important.

Representative DoH servers include Cloudflare 1.1.1.1 (fastest), Google 8.8.8.8 (stability), and Quad9 9.9.9.9 (security-focused, blocks malware domains). In Korea, 1.1.1.1 shows the fastest response time, averaging 10-20ms.

📊 DoH vs DoT Comparison

Category DoH (DNS over HTTPS) DoT (DNS over TLS)
Port 443 (HTTPS) 853 (dedicated)
Protocol HTTPS/HTTP2 Direct TLS connection
Censorship Bypass Easy (indistinguishable from web traffic) Difficult (dedicated port can be blocked)
Enterprise Management Difficult (cannot be monitored) Easy (port-based policies can be applied)
Performance HTTP/2 overhead present Faster (simple TLS)
Browser Support Chrome, Firefox, Edge, Safari OS-level configuration required

🌐 Major DoH Providers

Cloudflare
1.1.1.1 / 1.0.0.1
https://cloudflare-dns.com/dns-query
Fastest response speed, focus on privacy protection, logs deleted after 24 hours
Google Public DNS
8.8.8.8 / 8.8.4.4
https://dns.google/dns-query
High stability, global infrastructure, ECS support
Quad9
9.9.9.9 / 149.112.112.112
https://dns.quad9.net/dns-query
Security-focused, automatically blocks malware/phishing domains, nonprofit foundation
NextDNS
Provides personally configured IP
https://dns.nextdns.io/[설정ID]
Custom filtering, ad/tracker blocking, detailed statistics

💻 Code Example

# DoH 쿼리 (Cloudflare) - JSON 형식
curl -H "accept: application/dns-json" \
  "https://cloudflare-dns.com/dns-query?name=google.com&type=A"

# DoH 쿼리 (Google) - JSON 형식
curl "https://dns.google/resolve?name=google.com&type=A"

# DoH 쿼리 - DNS 와이어 형식 (바이너리)
curl -H "accept: application/dns-message" \
  "https://cloudflare-dns.com/dns-query?dns=AAABAAABAAAAAAAAB2dvb2dsZQNjb20AAAEAAQ"

# 응답 시간 측정
curl -w "DNS: %{time_namelookup}s, Total: %{time_total}s\n" -o /dev/null -s \
  "https://cloudflare-dns.com/dns-query?name=example.com&type=A"

# DoT 테스트 (853 포트, openssl 사용)
echo -e '\x00\x1d\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00\x07google\x03com\x00\x00\x01\x00\x01' | \
  openssl s_client -connect 1.1.1.1:853 -quiet 2>/dev/null | xxd

# 시스템 DoH 설정 (systemd-resolved, Linux)
# /etc/systemd/resolved.conf 수정
# [Resolve]
# DNS=1.1.1.1#cloudflare-dns.com
# DNSOverTLS=yes
import httpx  # pip install httpx
import json

# DoH 쿼리 (JSON API)
def doh_query_json(domain: str, record_type: str = "A") -> dict:
    """Cloudflare DoH JSON API로 DNS 쿼리"""
    url = "https://cloudflare-dns.com/dns-query"
    params = {"name": domain, "type": record_type}
    headers = {"accept": "application/dns-json"}

    response = httpx.get(url, params=params, headers=headers)
    return response.json()

# 사용 예시
result = doh_query_json("google.com", "A")
print(f"도메인: {result['Question'][0]['name']}")
for answer in result.get('Answer', []):
    print(f"  {answer['type']}: {answer['data']} (TTL: {answer['TTL']}s)")

# Google DoH 쿼리
def google_doh_query(domain: str) -> dict:
    """Google DoH JSON API"""
    url = f"https://dns.google/resolve?name={domain}&type=A"
    response = httpx.get(url)
    return response.json()

# DoH 서버 응답 속도 비교
import time

DOH_SERVERS = {
    "Cloudflare": "https://cloudflare-dns.com/dns-query?name=example.com&type=A",
    "Google": "https://dns.google/resolve?name=example.com&type=A",
    "Quad9": "https://dns.quad9.net:5053/dns-query?name=example.com&type=A"
}

for name, url in DOH_SERVERS.items():
    start = time.time()
    httpx.get(url, headers={"accept": "application/dns-json"})
    latency = (time.time() - start) * 1000
    print(f"{name}: {latency:.1f}ms")
// DoH 쿼리 (브라우저 / Node.js)
async function dohQuery(domain, type = 'A') {
    const url = `https://cloudflare-dns.com/dns-query?name=${domain}&type=${type}`;

    const response = await fetch(url, {
        headers: { 'accept': 'application/dns-json' }
    });

    return response.json();
}

// 사용 예시
const result = await dohQuery('google.com', 'A');
console.log('DNS 응답:', result);

result.Answer?.forEach(record => {
    console.log(`${record.name} -> ${record.data} (TTL: ${record.TTL}s)`);
});

// 여러 레코드 타입 조회
async function fullDnsLookup(domain) {
    const types = ['A', 'AAAA', 'MX', 'TXT', 'NS'];
    const results = {};

    await Promise.all(types.map(async type => {
        try {
            const data = await dohQuery(domain, type);
            results[type] = data.Answer || [];
        } catch (e) {
            results[type] = [];
        }
    }));

    return results;
}

// DNS 응답 시간 측정
async function measureDohLatency(server, domain) {
    const start = performance.now();
    await fetch(`${server}?name=${domain}&type=A`, {
        headers: { 'accept': 'application/dns-json' }
    });
    return performance.now() - start;
}

// 여러 DoH 서버 비교
const servers = {
    'Cloudflare': 'https://cloudflare-dns.com/dns-query',
    'Google': 'https://dns.google/resolve',
};

for (const [name, url] of Object.entries(servers)) {
    const latency = await measureDohLatency(url, 'example.com');
    console.log(`${name}: ${latency.toFixed(1)}ms`);
}

🗣️ Say It Like This in Practice

💬 In a Security Team Meeting
"There is a risk of DNS snooping on public Wi-Fi such as in cafés and airports. If we enable DoH by default on company devices, we can protect employees' web browsing privacy. We can configure it with Cloudflare 1.1.1.1 or NextDNS."
💬 When Discussing with the Network Team
"Adopting DoH can render existing DNS-based security solutions ineffective. In enterprise environments, we should use DoT (port 853) or set up an internal DoH proxy so that DNS traffic can be monitored. Otherwise, consider agent-based solutions such as Umbrella."
💬 In an Interview
"Both DoH and DoT are DNS encryption protocols, but DoH uses port 443 and cannot be distinguished from regular HTTPS traffic, while DoT uses dedicated port 853, which makes network management possible. DoH is suitable for personal privacy purposes, and DoT is suitable when running alongside enterprise security policies."

Take a mock interview on this topic → WIA SOOM AI Interview · Start for free

⚠️ Common Mistakes & Cautions

❌
Conflict with Enterprise Security Policies

DoH bypasses DNS-based content filtering and DLP solutions. In enterprise environments, use Firefox's canary domain check or disable DoH through group policy.

❌
Dependence on a Single DoH Server

If the DoH server fails, DNS resolution becomes impossible. Configure multiple DoH servers as fallbacks, such as Cloudflare + Google.

❌
Misconception of Complete Anonymity

DoH encrypts only DNS queries. The domain being accessed can be exposed through SNI (Server Name Indication). If you want complete privacy, you must also use ECH (Encrypted Client Hello).

✅
Correct DoH Configuration

Per-browser settings: Chrome (Settings > Privacy > Secure DNS), Firefox (Settings > Network Settings > Enable DNS over HTTPS). At the OS level, native support is available in Windows 11, iOS 14+, and Android 9+.

🔗 Related Terms

📚 Learn More