Snort Tutorial for Beginners
Franklin U.
Network Infrastructure Specialist | Cybersecurity expert | Committed to Enhancing Operational Performance | Linux Administrator.
What is Snort?
Snort is an open-source network intrusion detection and prevention system (IDS/IPS). It can analyze network traffic in real time, log packets, and detect malicious activities using predefined rules.
Key features:
Installing Snort
1. Prerequisites
Administrative privileges.
2. Update the System
$ sudo apt update && sudo apt upgrade -y
3. Install Dependencies
$ sudo apt install -y build-essential libpcap-dev libpcre3-dev libdumbnet-dev bison flex zlib1g-dev
4. Download and Install Snort
(Replace X.X with the latest version number.)
Extract and install Snort:
$ tar -xzvf snort-2.9.X.X.tar.gz
$ cd snort-2.9.X.X $ ./configure
$ make
$ sudo make install
Snort Operating Modes
Snort operates in three modes:
Snort Usage Examples
领英推荐
1. Sniffer Mode
To capture and display network packets in real-time:
$ sudo snort -v
-v: Verbose mode (shows packet headers).
2. Packet Logger Mode
To log packets to a directory: $ sudo snort -dev -l /var/log/snort
Captured logs can be viewed using: ls /var/log/snort
3. Intrusion Detection Mode
Run Snort with a configuration file and rule set:
$ sudo snort -c /etc/snort/snort.conf
Creating Snort Rules
Snort uses rules to detect suspicious activities. Rules are written in the following format: action protocol source_ip source_port -> destination_ip destination_port (options)
Example Rule
Detect ICMP (ping) traffic: alert icmp any any -> any any (msg:"ICMP traffic detected"; sid:1000001; rev:1;)
Steps to Add Rules
Save and exit.
Test the Rule
Restart Snort: $ sudo snort -c /etc/snort/snort.conf
Generate traffic to trigger the rule (e.g., visiting a website using HTTP). Check the logs in /var/log/snort.
Monitoring Snort Alerts
Alerts are stored in the directory configured in snort.conf. To view the alerts: $ cat /var/log/snort/alert
Troubleshooting Common Issues