Analyzing DNS over HTTPS (DoH) with Wireshark: A Comprehensive Guide

DNS over HTTPS (DoH) is a protocol that encrypts DNS queries and responses using HTTPS. This enhances privacy by preventing eavesdropping on DNS traffic. However, analyzing DoH traffic with a network protocol analyzer like Wireshark presents unique challenges because the DNS queries are hidden within HTTPS requests. This guide will walk you through the process of effectively analyzing DoH using Wireshark, highlighting key considerations and techniques.

Understanding the Challenges

Unlike traditional DNS over UDP or TCP, DoH encapsulates DNS messages within the payload of an HTTPS request. This means that a simple DNS filter in Wireshark won't reveal the DNS queries. You won't see the traditional DNS records; instead, you'll see seemingly innocuous HTTPS traffic. To analyze the DNS queries, you need to delve deeper into the HTTPS payload.

Setting up your Wireshark Capture

Before you begin, ensure you have Wireshark installed and running. The key is to capture traffic from the interface your machine uses to connect to the internet. If you're using DoH, the traffic will be directed to the DoH resolver's HTTPS endpoint (e.g., cloudflare-dns.com, dns.google).

Start a capture with Wireshark, focusing on the relevant network interface. Consider using a display filter to initially reduce noise: You can start with a simple filter like port 443 since DoH uses port 443 (the standard HTTPS port). This will show all HTTPS traffic, narrowing your focus.

Deciphering the HTTPS Payload

Once you have captured some traffic, the challenge lies in identifying and extracting the DNS data within the HTTPS payload. This usually involves these steps:

  1. Identify HTTPS Traffic to the DoH Resolver: Look for HTTPS traffic destined for your DoH provider's server (e.g., dns.google:443).
  2. Inspect the HTTP Request: Expand the HTTPS packet and look at the HTTP request. You'll see the HTTP headers. The crucial part here is often the POST request body, as it contains the DNS query in a specific format.
  3. Analyze the POST Body: The POST body generally contains the DNS query encoded in a format like DNS-over-HTTPS wire format (usually Protobuf). Wireshark might display it as a raw hexadecimal representation or as a partially-decoded structure depending on available dissectors.
  4. Use the Correct Protocol Dissector: Wireshark relies on dissectors to interpret different protocols. If you're encountering difficulty, ensure that the appropriate DoH dissector is installed and enabled. You may need to install additional dissectors provided by the Wireshark community.
  5. Follow the TCP Stream: For complex or fragmented DoH requests, selecting the HTTP request and then choosing "Follow TCP Stream" can be beneficial. This presents the entire HTTP conversation, potentially revealing more context.
  6. Apply DNS over HTTPS Filter (if available): Newer versions of Wireshark and custom dissectors may have advanced filters specific to DoH allowing you to quickly isolate the traffic. Check Wireshark's documentation and update to the latest version.

Advanced Techniques

For deeper analysis, you might consider:

Troubleshooting Tips

If you're having trouble, remember to:

Analyzing DoH with Wireshark requires patience and a careful understanding of HTTPS and the DNS protocol. By following these steps and utilizing advanced techniques when needed, you can successfully analyze and troubleshoot your DoH traffic.