tcpdump Filter Generator

Click together tcpdump filters from building blocks instead of memorising BPF syntax. You get a ready-to-run command for tcpdump, tshark or Wireshark plus a plain-language explanation.

Runs entirely in your browserVerified against libpcapFree, no sign-up

Examples to start with

Build your filter

Add rules, combine them with AND/OR, invert with NOT. Groups create parentheses.

Understanding tcpdump filters

tcpdump uses the libpcap filter syntax, often called BPF syntax (Berkeley Packet Filter). The same syntax applies to capture filters in Wireshark, tshark and dumpcap. A filter is made of simple primitives that you combine with and, or and not.

The primitives: type, direction, protocol

tcp dst port 443
src net 10.0.0.0/8
ether host 00:11:22:33:44:55

Combining and parentheses

In libpcap, and and or have the same precedence and are evaluated left to right. So a or b and c means (a or b) and c. Use parentheses whenever you mix the two. In the generator, every pair of parentheses comes from a group.

Always put the filter in single quotes, otherwise the shell interprets parentheses and special characters itself:

sudo tcpdump -nn -i eth0 'host 10.0.0.5 and (port 80 or port 443)'

Filtering TCP flags

tcp[tcpflags] gives you access to the flags in the TCP header. tcp[tcpflags] & (tcp-syn|tcp-ack) == tcp-syn matches only the first packet of each connection: SYN set, ACK not set. This only works for IPv4, because libpcap cannot locate the TCP header behind IPv6 extension headers.

Common filters

PurposeFilter
Traffic of one hosthost 192.168.1.10
Traffic between two hostshost 10.0.0.5 and host 10.0.0.20
Web without your own SSH session(port 80 or port 443) and not port 22
DNSport 53
DHCPudp portrange 67-68
Connection setuptcp[tcpflags] & (tcp-syn|tcp-ack) == tcp-syn
Connection resetstcp[tcpflags] & tcp-rst != 0
Pingicmp[icmptype] == icmp-echo
Packets in VLAN 100vlan 100 and host 10.1.1.1
Large packets (MTU issues)greater 1400

Practical tips

FAQ

How do I save a capture for Wireshark?

Enter a file name under Options in “Write to file (-w)”, e.g. capture.pcap. tcpdump then writes the raw packets to that file, which you can open directly in Wireshark.

Why does tcpdump say “syntax error”?

Usually the shell interprets parentheses or special characters because the filter is not quoted. The generator therefore always wraps the filter in single quotes. Other causes are typos in keywords or unbalanced parentheses.

Does the filter work in Wireshark too?

Yes, as a capture filter, because Wireshark also uses libpcap for that. Wireshark display filters use a different syntax, e.g. ip.addr == 10.0.0.5 instead of host 10.0.0.5.

Why does my filter find nothing on VLAN traffic?

With a VLAN tag, the IP header moves by 4 bytes. Put the VLAN rule first, e.g. vlan 100 and host 10.0.0.5. On some Linux systems the network card strips the tag beforehand, in which case you do not need vlan.

Is my input sent anywhere?

No. The generator runs entirely in your browser. The share link stores the filter in the part after the #, and browsers do not send that part to the server.