Rotate capture files by time

Start a new pcap file every hour with a timestamp in the name, good for unattended capture

tcpdump -nn -i any -G 3600 -w '/tmp/cap-%Y%m%d-%H%M%S.pcap'

tool
tcpdump18 commands
tags
tcpdumpmonitoringnetworkobservability

More tcpdump commands

  • tcpdump -nn -r /tmp/cap.pcap 'port 443 and host <ip>'

    Apply a BPF filter to a saved capture without capturing again

  • tcpdump -nn -e -i any port 53

    Show DNS lookups with MAC addresses (-e) to see which LAN client sent each query

  • tcpdump -i eth0 -n

    Capture all traffic on eth0 without resolving names

  • tcpdump -i eth0 -w /tmp/capture.pcap

    Save raw packets to a PCAP file to open later in Wireshark

  • tcpdump -r /tmp/capture.pcap -n | head -50

    Print packets from a saved PCAP file

all 18 tcpdump commands