How to capture last N seconds of packets using tcpdump

tcpdump

How can I capture the last N seconds of packets using tcpdump?

Best Answer

If you just want tcpdump to run for n seconds and then quit, you could use timeout.

For example:

timeout 2 tcpdump -eni mon0

Otherwise I don't believe tcpdump has an option to do this.

Related Question