Skip to content

Snort

75 commands

A network intrusion detection and prevention system that inspects traffic in real time against a rule language.

  • IDS
  • IPS
  • network monitoring

Install Snort

sudo apt install snort

Basic Snort Syntax2

snort -V

Displays the installed Snort version and build information to verify successful installation.

snort -?

Lists all available command-line switches and usage instructions for the current version.

Sniffer Mode Operation5

snort -v

Runs Snort in verbose mode to print TCP/IP packet headers to the console without logging.

snort -vd

Displays packet headers and application layer data (payloads) in verbose mode.

snort -vde

Displays packet headers, payloads, and Data Link Layer (Layer 2) headers for deep inspection.

snort -v -X

Dumps the raw packet data starting from the link layer in hex and ASCII format.

snort -e

Displays the Layer 2 (Data Link) headers, including MAC addresses, for captured packets.

Link

Interface Selection2

snort -i

Specifies the network interface to listen on for traffic capture and inspection.

Link
snort --help

Displays a summary of command-line options (synonym for -?).

Link

Packet Logger Mode4

snort -l

Logs captured packets to the specified directory, creating hierarchical folders based on IP addresses.

Link
snort -b

Logs packets in binary (tcpdump) format, which is much faster than ASCII logging.

Link
snort -K ascii

Forces Snort to log packets in ASCII format regardless of other default settings.

Link
snort -K none

Disables packet logging entirely, useful when only alerting is required to save disk space.

Link

Configuration File Usage2

snort -c

Loads the main configuration file containing rules, preprocessors, and variable definitions.

Link
snort -T

Validates the configuration file and rules for errors without actually starting the engine.

Link

Network Intrusion Detection Mode6

snort -A console

Prints alerts directly to the console screen for real-time monitoring of rule matches.

Link
snort -A fast

Logs alerts in a single-line format including timestamp, message, IPs, and ports for rapid parsing.

Link
snort -A full

Logs alerts with full packet header information, providing maximum context for each detection.

Link
snort -A unsock

Sends alerts to a UNIX socket for processing by external programs.

Link
snort -A none

Disables internal alerting, typically used when logging is handled strictly by Unified2 output.

Link
snort -q

Runs Snort in quiet mode, suppressing banner and initialization messages to focus on alerts.

Link

Alert Generation1

snort -A cmg

Generates 'cozy' alerts that display the packet payload in hex and text alongside the alert message.

Link

Packet Capture Handling5

snort -r

Reads and processes a single PCAP file through the NIDS engine instead of listening on an interface.

Link
snort --pcap-dir

Recursively processes all PCAP files found within the specified directory.

Link
snort --pcap-filter

Filters the files in a PCAP directory to only process those matching a specific shell pattern.

Link
snort --pcap-show

Displays the name of the PCAP file currently being processed during a bulk read operation.

Link
snort --pcap-reset

Resets the internal Snort state between processing each PCAP file in a directory to ensure clean tests.

Link

Blue Team Detection Validation1

snort -r -n

Processes only the first N packets of a capture file, useful for quick rule validation on large files.

Link

Performance Tuning5

snort -N

Disables packet logging regardless of configuration, retaining only alerts to improve I/O performance.

Link
snort -D

Runs Snort as a background daemon process, detaching it from the current terminal session.

Link
snort -k none

Disables checksum verification, useful if packets are captured on interfaces performing checksum offloading.

Link
snort --search-method

Forces the use of a specific pattern matching algorithm (e.g., Aho-Corasick) for performance testing.

Link
snort --max-packet-threads

Limits the number of packet processing threads (Snort 3 specific or experimental threading builds).

Link

Rule Management2

snort --dump-dynamic-rules

Exports loaded dynamic rules (shared object rules) to text files for inspection and debugging.

Link
snort --pause

Starts Snort but pauses processing immediately, waiting for a resume signal, used in synchronized testing.

Link

Custom Rule Testing1

snort -S

Overrides variable definitions from the command line without modifying the configuration file.

Link

SOC Monitoring Workflow3

BPF Filtering

Applies a Berkeley Packet Filter (BPF) at the end of the command to ignore specific traffic (e.g., SSH).

Link
snort -u -g

Runs Snort as a specific user and group to minimize security risks associated with running as root.

Link
Show Application Data

Dumps the application layer (payload) data for captured packets, useful for inspecting HTTP or DNS bodies.

Link

Output Formats2

snort -L

Sets the base filename for binary log files when running in packet logger mode.

Link
snort -U

Forces timestamps in logs to use UTC instead of the local system timezone.

Link

Advanced Usage4

snort --snaplen

Sets the snap length (packet capture size) manually, ensuring full packet capture for jumbo frames.

Link
snort -M

Logs console messages to syslog in addition to printing them to the screen.

Link
snort --conf-error-out

Forces Snort to stop processing and exit immediately upon encountering the first configuration error.

Link
snort --create-pidfile

Forces creation of a PID file even if Snort is not running in daemon mode.

Link

Preprocessor Configuration1

snort --disable-inline-init

Allows Snort to run in inline mode without requiring hardware bridging initialization.

Link

Inline and IPS Mode4

snort -Q

Enables Inline Mode (IPS), allowing Snort to drop packets defined by 'drop' rules.

Link
snort --daq

Specifies the Data Acquisition (DAQ) module type (e.g., pcap, afpacket, nfq) for packet I/O.

Link
snort --daq-dir

Tells Snort where to look for DAQ modules if they are not in the standard system library path.

Link
snort --daq-list

Lists the available Data Acquisition (DAQ) modules installed on the system.

Link

Purple Team Simulation1

snort -O

Obfuscates IP addresses in printed logs to sanitize data during sensitive sharing or testing.

Link

Blue Team Defensive Validation2

snort --warn-all

Enables all warning messages during configuration loading to identify potential rule syntax issues.

Link
Capture and Analyze

Workflow: Captures traffic to binary first, then analyzes it offline with full rules to minimize packet drops.

Link

Incident Response Investigation2

snort --logid

Appends a specific Log ID to output filenames to distinguish between parallel Snort instances.

Link
snort -y

Includes the year in the timestamp of alert logs, critical for long-term forensic timelines.

Link

Automation and Scripting2

snort --pid-path

Specifies the directory where the PID file should be written, essential for service management scripts.

Link
snort --nolock-pidfile

Creates the PID file without locking it, useful in specific containerized or scripted environments.

Link

Debugging Rules1

snort --rule-to-hex

Outputs the binary rule database in a hex format, typically used for low-level rule engine debugging.

Link

Advanced Combined Workflow8

Validate Local Rules

Validates the main config while dynamically adding a custom rule path not defined in the main file.

Link
Offline PCAP Forensics

Analyzes a malware PCAP ignoring checksums and generating full-detail alerts for forensic review.

Link
High Performance Sniffing

Captures packets to a binary log file with no checksums or alerting for maximum write speed.

Link
Rule Profiling

Runs against a directory of PCAPs and prints performance statistics for the top CPU-consuming rules.

Link
Preprocessor Profiling

Profiles the performance of enabled preprocessors to identify bottlenecks in inspection modules.

Link
Packet Data Printing

Prints packet data in a character-only format, omitting hex dumps, for easier reading of text payloads.

Link
Specific Interface Type

Passes specific variables to the DAQ module, such as increasing the buffer size to prevent packet loss.

Link
Alert to Syslog Only

Sends alerts to syslog facilities and discards local log files by pointing the log directory to null.

Link

Interface Configuration1

snort --address

Specifies the IP address of the listening interface if Snort cannot auto-detect it correctly.

Link

Cleanup and Termination2

Signal Handling

Sends a SIGHUP signal to the Snort process to force it to reload the configuration file and restart.

Link
Signal Handling

Forces Snort to dump current packet capture statistics to the console/syslog without stopping the process.

Link

Purple Team Attack Simulation1

Verbose Replay Inspection

Replays exploit traffic quietly while showing 'cozy' alerts with payload data to confirm signature match location.

Link

Logging Behavior2

snort -n

Processes only the specified number of packets and then exits automatically.

Link
snort -t

Chroots the Snort process to a specific directory after initialization for enhanced security isolation.

Link

Output Plugins1

CSV Output

Customizes the output format of logs (if CSV output plugin is enabled) by defining the separator character.

Link

Debugging and Development1

snort --version

Prints the full version information including library versions and compiler options.

Link

Clean Termination1

Quit

Gracefully shuts down the Snort process, ensuring all logs are flushed and closed properly.

Link