Build tcpdump BPF filters without guessing the syntax
tcpdump uses Berkeley Packet Filter expressions to capture only the traffic you
care about. This tool lets you assemble a filter from host, network, port,
protocol, direction and TCP-flag primitives, joining them with and/or/not,
and includes a reference of the primitives. It runs entirely in your browser.
How it works
A BPF filter is a boolean expression over per-packet primitives. Common
primitives are host, net, port, portrange, a bare protocol name
(tcp, udp, icmp), and direction qualifiers src/dst. Combine them with
and, or and not, using parentheses (quoted in the shell) for grouping:
tcpdump -i eth0 "tcp and host 10.0.0.5 and port 443"
tcpdump -i any "udp port 53 or icmp"
tcpdump -i eth0 "tcp[tcpflags] & tcp-syn != 0 and not net 10.0.0.0/8"
Tips and examples
- Always quote the filter expression so the shell does not interpret
parentheses,
<,>or&. tcp[tcpflags] & tcp-syn != 0catches connection attempts; combine withand tcp[tcpflags] & tcp-ack == 0to find bare SYNs (no ACK).- Use
-nto skip DNS resolution and-nnto also skip port-name lookup, keeping the capture fast and the output literal. - Capture filters run in the kernel and drop non-matching packets entirely, unlike Wireshark display filters that only hide captured packets.