Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to apply a read filter on a .pcap file using tshark based on the interface?

Can I do something like :

tshark -r filename.pcap -R -i wan0 ?

Where filename.pcap is the packet capture file being analysed and wan0 is the interface for which I need to apply the filter?

like image 815
Rohit Rane Avatar asked Oct 12 '25 05:10

Rohit Rane


1 Answers

The normal pcap format as used by tcpdump does not contain information about the interface name where a packet was captured. The pcapng format as used by tshark or wireshark by default does have this information. With pcapng one could apply a display filter like this:

tshark -r file.pcapng -Y 'frame.interface_name == "wan0"'

Of course, this makes only sense if the pcapng file contains packets captured on multiple interfaces. Otherwise this filter would just result in no packets or all packets. Specifically it will not help to capture on the any pseudo-interface since the pcapng will not contain the names of the various interfaces on the system but just show all packets captured on the single any pseudo-interface.

like image 90
Steffen Ullrich Avatar answered Oct 16 '25 07:10

Steffen Ullrich