tcpdump BPF Filter Reference

tcpdump BPF filter expressions — host, port, proto, flags — with combination logic.

Build and look up tcpdump/BPF capture filter expressions — host, net, port, protocol and TCP flag primitives — combined with and/or/not, with a live filter builder.

What is a BPF capture filter?

A Berkeley Packet Filter is a low-level expression the kernel uses to decide which packets to hand to tcpdump. Filters combine primitives like host, port and proto with the boolean operators and, or and not, evaluated per packet.

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 != 0 catches connection attempts; combine with and tcp[tcpflags] & tcp-ack == 0 to find bare SYNs (no ACK).
  • Use -n to skip DNS resolution and -nn to 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.