From Wikipedia, the free encyclopedia
Jump to: navigation, search
Developer(s) Jordan Ritter
Stable release 1.45 / November 28, 2006; 7 years ago (2006-11-28)
Written in C
Operating system Linux, Solaris, FreeBSD, NetBSD, OpenBSD, Mac OS X, additional *NIX systems, Windows
Type Packet analyzer
License BSD-style[1]

ngrep (network grep) is a network packet analyzer written by Jordan Ritter.[2] It runs under the command line, and relies upon the pcap library and the GNU regex library.

ngrep support Berkeley Packet Filter (BPF) logic to select network sources or destinations or protocols, and also allow to match patterns or regular expressions in the data payload of packets using GNU grep syntax, showing packet data in a human-friendly way.

ngrep is an open source application, and the source code is available to download from the ngrep site at SourceForge. It can be compiled and ported to multiple platforms, it works in many UNIX-like operating systems: Linux, Solaris, BSD, AIX, and also works on Microsoft Windows.[3]


ngrep is similar to tcpdump, but it has the ability to look for a regular expression in the payload of the packet, and show the matching packets on a screen or console. It allows users to see all unencrypted traffic being passed over the network, by putting the network interface into promiscuous mode.

ngrep with an appropriate BPF filter syntax, can be used to debug plain text protocols interactions like HTTP, SMTP, FTP, DNS, among others, or to search for a specific string or pattern, using a grep regular expression syntax.[4][5]

ngrep also can be used to capture traffic on the wire and store pcap dump files, or to read files generated by other sniffer applications, like tcpdump, or wireshark.

ngrep has various options or command line arguments. The ngrep man page in UNIX-like operating systems show a list of available options.

Using ngrep[edit]

Typical use of ngrep.

# Capture and show network traffic incoming to eth0 interface and 
# show parameters following HTTP GET or POST methods
ngrep -l -q -d eth0 "^GET |^POST " tcp and port 80
# Capture and show network traffic incoming to eth0 interface and 
# show the HTTP User-Agent string  

ngrep -l -q -d eth0 "User-Agent: " tcp and port 80
# Capture and show network traffic incoming to eth0 interface and 
# show the DNS querys and responses  

ngrep -l -q -d eth0 "" udp and port 53


Capturing raw network traffic from an interface requires special privileges or superuser privileges on some platforms, especially on Unix-like systems. ngrep default behavior is to drop privileges in those platforms, running under a specific unprivileged user.

Like tcpdump, it is also possible to use ngrep for the specific purpose of intercepting and displaying the communications of another user or computer, or an entire network.

A privileged user running ngrep in a server or workstation connected to a device configured with port mirroring on a switch, router, or gateway, or connected to any other device used for network traffic capture on a LAN, MAN, or WAN, can watch all unencrypted information related to login ID's, passwords, or URLs and content of websites being viewed in that network.[6]

Supported Platforms[edit]

Supported Protocols[edit]

See also[edit]


  1. ^ LICENSE.txt file in the tarball
  2. ^ Jordan Ritter at CrunchBase
  3. ^ ngrep supported platforms
  4. ^ ngrep and regular expressions
  5. ^ ngrep usage
  6. ^ Network monitoring with ngrep

External links[edit]