CHAPTER 11
Beginner
Filtering Packets in Wireshark
Updated: May 16, 2026
20 min read
# CHAPTER 11
Filtering Packets in Wireshark
1. Introduction
A 60-second capture on a busy enterprise server will generate hundreds of thousands of packets. Scrolling through that list to find a single broken database connection is like looking for a needle in a haystack while the haystack is actively burying you. Wireshark's true power does not lie in its ability to capture data, but in its ability to filter data. In this chapter, we will master the Wireshark filter syntax. We will learn the critical difference between Capture Filters and Display Filters, and we will build a mental cheat sheet of IP, Port, and Protocol filters using boolean logic (AND/OR) to surgically isolate the exact packets we need.2. Learning Objectives
By the end of this chapter, you will be able to:- Differentiate between a Capture Filter and a Display Filter.
- Construct Display Filters for specific IP addresses and Subnets.
- Filter traffic based on specific TCP and UDP port numbers.
-
Combine multiple filters using logical operators (
&&,||,!).
- Utilize Wireshark's right-click "Apply as Filter" shortcut.
3. Capture Filters vs. Display Filters
These are two fundamentally different concepts with different syntax.Capture Filters:
- *When they are used:* BEFORE you start the capture.
-
*What they do:* They tell Wireshark to *ignore* everything else. If you set a capture filter for
port 80, Wireshark drops all DNS, VoIP, and HTTPS traffic into the trash before it even hits your RAM.
- *Why use them?* To save hard drive space and prevent memory crashes on extremely busy networks.
Display Filters:
- *When they are used:* AFTER you have captured the data (or during the capture in the top bar).
-
*What they do:* They temporarily *hide* packets from the screen. The hidden packets are still saved in memory and in the
.pcapfile. You can bring them back anytime.
- *Why use them?* Because they are non-destructive. This is what you will use 99% of the time.
4. The Display Filter Syntax Cheat Sheet
The Display Filter bar is the long green/red text box at the top of Wireshark. (If it turns red, your syntax is wrong).Filtering by Protocol:
-
http(Shows only unencrypted web traffic)
-
dns(Shows only Domain Name System traffic)
-
tcporudp
Filtering by IP Address:
-
ip.addr == 192.168.1.50(Shows all traffic going TO or coming FROM that IP).
-
ip.src == 192.168.1.50(Shows only traffic sent BY that IP).
-
ip.dst == 8.8.8.8(Shows only traffic sent TO that IP).
Filtering by Port Number:
-
tcp.port == 443(Shows all HTTPS traffic).
-
udp.port == 53(Shows all DNS traffic).
5. Advanced Filtering: Logical Operators
You rarely search for just one thing. You need to chain filters together using Boolean logic.-
AND (
&&orand): Both conditions must be true.
ip.addr == 192.168.1.50 && tcp.port == 80 (Show me HTTP traffic ONLY for this specific computer).
-
OR (
||oror): Either condition can be true.
tcp.port == 80 || tcp.port == 443 (Show me all Web traffic, both encrypted and unencrypted).
-
NOT (
!ornot): Exclude this traffic.
!(ip.addr == 192.168.1.100) (Show me everything on the network EXCEPT traffic from the loud, noisy backup server).
6. The "Apply as Filter" Shortcut
You do not have to memorize every command. Wireshark has a brilliant UI feature.- 1. Find a packet you like in the list.
- 2. Expand the Middle Pane (Details).
- 3. Right-click on *any* field (e.g., the MAC address, the TTL, the TCP Sequence number).
- 4. Select "Apply as Filter" -> "Selected".
- 5. Wireshark automatically types the perfect, complex syntax into the top bar and applies it!
7. Filter Examples in Practice
*Scenario: Find a failed HTTP connection.*-
1.
Filter:
tcp.flags.reset == 1 && tcp.port == 80
*Scenario: Find all traffic to a specific Subnet.*
-
1.
Filter:
ip.addr == 10.0.5.0/24
10.0.5.x department.
8. Best Practices
-
Save Custom Filter Buttons: Next to the Display Filter bar, there is a
+button. If you find yourself typingip.addr == 10.0.1.50 && tcp.port == 3306every single day to check a database, click the+to save it as a permanent button on your toolbar.
9. Common Mistakes
-
Confusing
==with=: The most common syntax error for beginners. In Display Filters, you MUST use two equal signs (==) to check for equality. If you typeip.addr = 192.168.1.1, the bar will turn red, and the filter will fail.
10. Mini Project: Build a Composite Filter
- 1. Open a previously saved PCAP file (or capture some live web browsing).
-
2.
Write a filter to find all HTTPS traffic:
tcp.port == 443
- 3. Now, refine it. Write a filter to find all HTTPS traffic that is specifically setting up a new connection (The SYN packet):
tcp.port == 443 && tcp.flags.syn == 1
- 4. Press Enter. You have just isolated the very first millisecond of every secure web request in the capture!
11. Practice Exercises
- 1. Explain the operational and data-retention differences between a Capture Filter and a Display Filter.
-
2.
Write the exact Wireshark Display Filter syntax required to show all traffic originating from the IP
10.0.0.5that is NOT using UDP port53.
12. MCQs with Answers
Question 1
When typing a Display Filter in Wireshark to isolate traffic to a specific IP address, which syntactic operator must be used?
Question 2
What is the primary advantage of utilizing a Display Filter instead of a Capture Filter?
13. Interview Questions
- Q: A junior analyst is running a 24-hour capture to catch a rare network event. They complain that Wireshark keeps crashing due to memory exhaustion. How would you solve this using filters? Explain the mechanism.
-
Q: Write a Wireshark Display Filter to isolate all HTTP and HTTPS traffic involving the specific server IP
172.16.0.50.
- Q: Explain the functionality and workflow of the right-click "Apply as Filter" feature in the Wireshark GUI.
14. FAQs
Q: Can I filter by a domain name instead of an IP address? A: Yes, but with a major caveat. You can typehttp.host == "google.com", but this ONLY searches the unencrypted Layer 7 HTTP headers. It will not find HTTPS traffic, and it will not find the underlying TCP handshakes. Filtering by raw IP addresses is always faster, more accurate, and protocol-agnostic.
15. Summary
In Chapter 11, we acquired the most crucial operational skill in Wireshark: the ability to filter. We differentiated between the destructive nature of Capture Filters (saving disk space) and the exploratory nature of Display Filters. We mapped the foundational syntax for IP addresses (ip.addr ==), TCP/UDP Ports, and application protocols. By weaving these commands together with boolean logic (&&, ||, !), we transformed Wireshark from a chaotic firehose of binary data into a precision search engine capable of isolating a single connection in milliseconds.