Filter Queries with -Y "dns.qry.name"
In this step, you will learn how to filter DNS queries in Wireshark using display filters. DNS (Domain Name System) is like the phonebook of the internet, translating human-readable domain names into machine-readable IP addresses. When troubleshooting network issues, examining DNS traffic can reveal important clues.
We'll focus on the dns.qry.name
field, which specifically shows the domain names being requested in DNS queries. This is particularly useful when you need to examine traffic related to specific websites or services from the capture we created in the previous step.
- First, let's open the capture file we saved earlier in Wireshark. The
&
at the end runs the command in the background so you can continue using the terminal:
wireshark ~/project/dns_capture.pcapng &
- In Wireshark's display filter bar (the empty field just below the toolbar), enter this exact filter to see only DNS queries for "example.com":
dns.qry.name == "example.com"
This strict equality filter (==
) will show only packets where the queried domain exactly matches "example.com".
- To see all DNS queries regardless of the domain being requested, simply use the field name by itself:
dns.qry.name
This displays all packets that contain DNS query names, which helps you understand what domains are being looked up on your network.
- For a more complete view showing both DNS queries (requests) and responses, use this filter that checks the DNS response flag:
dns.flags.response == 0 || dns.flags.response == 1
Here, dns.flags.response == 0
shows queries (requests), while dns.flags.response == 1
shows responses.
- Sometimes you might want to find all queries related to a certain organization or service. Try filtering for partial domain matches using the "contains" operator:
dns.qry.name contains "example"
This will match any domain containing "example", like "example.com", "test.example.org", or "example.net".
Key points to understand:
-Y
is Wireshark's display filter option (equivalent to typing in the filter bar)
dns.qry.name
is a specific field in DNS packets that contains the domain name being queried
- Display filters help you focus on specific traffic patterns by hiding unrelated packets
- Filters can use different comparison operators:
==
for exact matches
!=
for exclusion
contains
for partial matches
- The DNS protocol includes flags to distinguish between queries (
response == 0
) and responses (response == 1
)