tcpdump
Terminal packet capture, BPF filters, .pcap files and troubleshooting from dumps
Terminal packet capture, BPF filters, .pcap files and troubleshooting from dumps
tcpdump reads packets straight off a network interface through an AF_PACKET socket and the kernel BPF filter — on any server over SSH, with no GUI or heavy dependencies. It shows what hits the wire and comes back when application logs stay silent or contradict each other.
-nn, -c, -v, -A, writing .pcap files, and reading every field of an output line.host, net, port, boolean logic, the tcp[13] flags byte, and checking bytecode with -d.DROP, RST, MTU black hole, DNS, TLS SNI, and capturing inside a container..pcap dumps on one screen.-nn, tcpdump sends a reverse DNS (PTR) lookup for every new IP address and translates port numbers using /etc/services.tcpdump and the firewall: inbound packets appear before drop, outbound afterSeeing an inbound SYN in tcpdump does not mean the firewall let it through: an AF_PACKET socket captures inbound frames before netfilter hooks.-i any in tcpdump: Linux SLL2 header, no destination MAC, and no promiscuous modetcpdump -i any captures traffic across all interfaces at once and prints the interface name with direction (In/Out), but replaces the Ethernet header with a LINUX_SLL2 pseudo-header: destination MAC is missing, ether filters fail, and promiscuous mode stays off.vlan filter in tcpdump: put it first, or L3/L4 offsets won't matchThe vlan primitive in a BPF filter checks for an 802.1Q tag and shifts all header offsets to its right by +4 bytes.Capturing .pcap in production: -C and -W ring buffer instead of an unbounded fileA forgotten tcpdump -w /tmp/dump.pcap on a production server fills the disk to 100% within hours and takes down databases and containers.