Back to library
Defensive Intermediate Free

Capture packets on eth0, rotating files, excluding SSH traffic

Capture packets on eth0, rotating files, excluding SSH traffic

Tcpdump / Network Monitoring

Log in to save

Command

tcpdump -i eth0 -w /tmp/capture.pcap -C 100 -W 10 port not 22

Syntax

tcpdump -i <interface> -w <file> [filters]

Use case

Long-running network capture during incident response or threat hunting to capture suspicious traffic without filling disk or mixing with analyst SSH sessions.

Explanation

Professional packet capture setup: • -i eth0 → Listen on eth0 interface • -w → Write raw packets to pcap file • -C 100 → Rotate file every 100MB • -W 10 → Keep max 10 rotated files (ring buffer) • port not 22 → Exclude SSH to reduce noise Open captures in Wireshark for analysis. Use -r capture.pcap to read and filter saved captures.

Example output

tcpdump: listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes
Rotating output to /tmp/capture1.pcap
Rotating output to /tmp/capture2.pcap

More examples

Primary example

tcpdump -i eth0 -w /tmp/capture.pcap -C 100 -W 10 port not 22

Long-running network capture during incident response or threat hunting to capture suspicious traffic without filling disk or mixing with analyst SSH sessions.

linux macos tcpdump packet-capture pcap network monitoring

Related

Defensive Advanced Premium

Process a packet capture with Zeek local policy.

Process a packet capture with Zeek local policy.

zeek -r sample.pcap local
zeek network-monitoring expanded-library
Zeek / Network Monitoring Open
Defensive Advanced Premium

Summarize network services from Zeek connection logs.

Summarize network services from Zeek connection logs.

zeek-cut id.orig_h id.resp_h service < conn.log | sort | uniq -c
zeek network-monitoring expanded-library
Zeek / Network Monitoring Open
Defensive Advanced Premium

Inspect DNS queries and answers.

Inspect DNS queries and answers.

zeek-cut query answers < dns.log | head
zeek network-monitoring expanded-library
Zeek / Network Monitoring Open