grep applied to the network layer
open sourcengrep License (BSD-style, with an advertising clause)self-hostablefree
ngrep (network grep) is like GNU grep applied to the network layer: it captures packets through libpcap and matches their payloads against an extended regular expression or a hex pattern, using the same BPF filter syntax as tcpdump. It understands IPv4 and IPv6, TCP, UDP, ICMP, IGMP and raw packets on many interface types, prints matching packets as text (UTF-8 too), and reads and writes pcap files. It was made for debugging plaintext protocols such as HTTP, IMAP, DNS and SIP and for spotting unusual traffic, and version 1.49.0 (February 2026) resolves Docker and Podman container names. Written in C by Jordan Ritter, with release binaries for Linux, macOS, the BSDs, Solaris and Windows and an image on GitHub's container registry, under a BSD-style licence (GPL when built against GNU regex instead of PCRE2).
Ways to install
Package managers
Problems it solves
- grep live network traffic for a string the way grep searches files
- see which HTTP requests reach my server matching a URL pattern, without a proxy
- watch SIP messages on a VoIP server to debug call setup
- search a saved pcap file for packets whose payload matches a regex or hex bytes
- find which container on a Docker host is sending a particular request
- spot traffic whose payload matches a malware pattern on the wire
- print packet payloads as readable text instead of a hex dump
- debug a plaintext protocol exchange like IMAP or DNS by watching the packets
Features
- regex (PCRE2 or GNU regex) and hex pattern matching on packet payloads
- BPF filter expressions like tcpdump
- IPv4/6, TCP, UDP, ICMPv4/6, IGMP and raw packets
- reads and writes pcap files
- UTF-8 payload display
- Docker and Podman container name resolution (-r)
- tcpkill-style connection killing (optional build)
- binaries for Linux, macOS, FreeBSD, NetBSD, OpenBSD, Solaris and Windows; Docker image
Capabilities
| Has a command line tool | plan not known |
|---|
Alternatives
The same job
These do what ngrep does.
