← 返回命令列表

Linux command

sngrep 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Capture SIP traffic

sngrep

Capture on interface

sngrep -d [eth0]

Read from pcap

sngrep -I [capture.pcap]

Show only INVITE dialogs

sngrep -c

Capture to file

sngrep -O [output.pcap]

Filter by IP using BPF

sngrep host [192.168.1.100]

Capture without interface

sngrep -N -q -O [output.pcap]

说明

sngrep is a terminal-based tool for capturing and analyzing SIP (Session Initiation Protocol) traffic used in VoIP systems. It provides an interactive ncurses interface that displays active SIP dialogs, call flow diagrams with directional arrows, and full message content including headers and body. The tool captures SIP packets in real time from network interfaces or reads previously captured pcap files for offline analysis. Filters narrow results by SIP method, source or destination address, and custom BPF expressions. Captured traffic can be saved to pcap format for later review or sharing with other analysis tools. Call flow visualization is the tool's standout feature, showing the sequence of SIP messages (INVITE, 200 OK, ACK, BYE) between endpoints with timing information. This makes it particularly effective for diagnosing VoIP call setup failures, registration problems, and codec negotiation issues.

参数

-d _DEVICE_
Capture device (or comma-separated list).
-I _FILE_
Read packets from pcap file.
-O _FILE_
Save captured packets to pcap file.
-c
Only display dialogs starting with INVITE.
-l _LIMIT_
Maximum number of dialogs to capture.
-N
No interface mode (capture only).
-q
Quiet mode (suppress output in no-interface mode).
-r
Capture RTP packet payloads.
-R
Rotate calls when capture limit is reached.
-k _FILE_
RSA private key for TLS decryption.
-B _SIZE_
Pcap buffer size in MB (default: 2).
-H _URL_
Send captured packets to Homer sipcapture URL.
-f _FILE_
Load specific configuration file.
-D
Print active configuration and exit.

FAQ

What is the sngrep command used for?

sngrep is a terminal-based tool for capturing and analyzing SIP (Session Initiation Protocol) traffic used in VoIP systems. It provides an interactive ncurses interface that displays active SIP dialogs, call flow diagrams with directional arrows, and full message content including headers and body. The tool captures SIP packets in real time from network interfaces or reads previously captured pcap files for offline analysis. Filters narrow results by SIP method, source or destination address, and custom BPF expressions. Captured traffic can be saved to pcap format for later review or sharing with other analysis tools. Call flow visualization is the tool's standout feature, showing the sequence of SIP messages (INVITE, 200 OK, ACK, BYE) between endpoints with timing information. This makes it particularly effective for diagnosing VoIP call setup failures, registration problems, and codec negotiation issues.

How do I run a basic sngrep example?

Run `sngrep` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -d _DEVICE_ do in sngrep?

Capture device (or comma-separated list).