How can I see traffic while I am capturing it with tcpdump.
When I use -w, it doesn't show the packets during the capture.
sudo tcpdump -i enp2s0 -w test.pcap
tcpdump: listening on enp2s0, link-type EN10MB (Ethernet), capture size 262144 bytes
^C6 packets captured
7 packets received by filter
0 packets dropped by kernel
So after a bit of experiment, the anwser if the following :
-w -
: write to standard output.-U
: write packets as soon as they arrive. Don't wait until the buffer is full.Tee
will write to the file, andtcpdump -r -
read the packets from standard input.-w
option is to write the tcpdump output to a file. you can remove that option if you want to print on your terminal.Since you are using the option -w, the packets are being saved to the file and not displayed at the standard output. Here from the tcpdumup manpage:
https://www.tcpdump.org/manpages/tcpdump.1.html
If you want to do both at the same time, here is a way to achieve that:
How can I have tcpdump write to file and standard output the appropriate data?
To attach a new process to an ongoing dump, try:
tail -F -n+0 $dumpfile | tcpdump -r -