How to apply and edit Wireshark display filters

Wireshark display filters enable users to narrow the scope of a network traffic scan. Use this tutorial to apply and edit display filters to make detailed network sniffing easier.

The open source Wireshark tool enables users to analyze network traffic at the micro level, sniff network packets, troubleshoot network issues and more. But, before jumping into this versatile tool, it is important to understand its features. One such feature to figure out before testing is display filters.

Wireshark display filters help narrow the scope of traffic analysis during packet filtering, said Lisa Bock, author of Learn Wireshark: A definitive guide to expertly analyzing protocols and troubleshooting networks using Wireshark, Second Edition.

In the following excerpt from Chapter 7 of her book, "Using Display and Capture Filters," Bock explains about how to create, edit and use display filters. Download a PDF of Chapter 7 to also learn how to create capture filters, filter network traffic, use shortcuts and more.

Check out an interview with Bock, where she elaborates on Wireshark use cases and how to use Wireshark profiles.

Comprehending display filters

While capturing traffic, or analyzing a pre-captured file, display filters help to narrow the scope and home in on specific types of traffic. It's not uncommon to have a capture with over 3,000 packets containing many different types of traffic.

When you launch Wireshark, you will see the startup screen. Across the top, below the icons, is the filter toolbar. Within the toolbar is the text Apply a display filter..., where you can easily apply and edit display filters, as shown here:

Screenshot of the Wireshark startup screen
Figure 7.6 - Wireshark startup screen

You can create a simple filter on any of the protocols Wireshark supports by using a single protocol or adding a logical operator. For example, if you want to see TCP or ARP traffic, then you would use the tcp || arp display filter.

Screenshot of Learn Wireshark book coverCheck out more on Learn

Wireshark's display filters can easily be modified. The following section illustrates how you can edit the display filters to customize your workflow.

Editing display filters

After working with the display filters, you may need to change an IP address, port number, or make some other change. To edit the display filter, go to the Analyze menu, and then select Display Filters..., which will bring up the following dialog box:

Screenshot of the Wireshark Display Filters
Figure 7.7 - Display Filters dialog box

Once there, you can select one of the three icons as shown in the lower left-hand corner of the Display Filters dialog box:

  • A plus icon will add a new display filter. When selected, Wireshark will create a space where you enter a name on the left and the actual filter on the right, as shown in Figure 7.7.
  • A minus icon will delete a display filter. Select (highlight) the filter you want to remove and hit the minus sign to remove the filter from the dialog box and update the dfilters.txt file.
  • A copy icon will copy a display filter. Once copied, you can modify the filter without changing the original. Wireshark will then add the new filter to the dfilters.txt file.

In the next section, we'll see how, when you do get a display filter that works and you would like to reuse it, you can save it to a bookmark.

Using bookmarks

On the right-hand side of the display filter, there is a blue toolbar icon called bookmarks. This is where Wireshark's built-in filters and any user-saved filters reside. If you click on the icon you will see options, along with several pre-loaded filters that you can use, as shown here:

Screenshot of the Wireshark display filter bookmarks
Figure 7.8 - Display filter bookmark dropdown

When working with bookmarks, you will see configuration options that include the following:

  • Save this filter: After you create a filter, you can save the filter to the bookmark by selecting this option.
  • Remove this filter: This will delete the filter currently in use that is stored in the dfilters.txt file.
  • Manage Display Filters: This will open the Display Filters dialog box.
  • Filter Button Preferences...: This will open the Preferences dialog box with the Filter Buttons option highlighted.

Below the selections, you will see a list of filters. Even if you have never saved a filter, you will see the list, as Wireshark will show the list of filters found in the dfilters.txt file.

Once you create your own filter or select one from the drop-down list, you can press Enter or click the blue arrow on the right-hand side of the display filter to run the filter.

On the far-right side of the display filter is a drop-down arrow (caret). When selected, you can see previously used filters, as shown in the following screenshot:

Screenshot of the Wireshark previously used display filters
Figure 7.9 - Previously used display filters

A display filter can be applied before, during, or after packet capture. When you are ready to clear the filter, select the X on the right-hand side of the filter, as shown here:

Screenshot of the Wireshark display filter toolbar
Figure 7.10 - The display filter toolbar

As we can see, display filters can be very helpful in providing a more targeted view of the capture. However, there may be times that you only want to gather a certain type of traffic. In that case, you would use a capture filter, which we'll discuss in the next section.

Dig Deeper on Network security

Enterprise Desktop
Cloud Computing