Securing your Network with Snort

Securing your network with Snort is a powerful way to detect and prevent threats in real-time. Snort is an open-source network intrusion detection system (NIDS) and intrusion prevention system (NIPS) that analyzes network traffic for malicious activity.

Below is a comprehensive guide on how to secure your network using Snort , including installation, configuration, rule management, and integration options.


๐Ÿ” What is Snort?

Snort is often referred to as the “Swiss Army Knife” of network security monitoring. It works by capturing packets, analyzing them against a set of rules, and generating alerts or blocking traffic when suspicious behavior is detected.

Key Features:

  • Real-time traffic analysis
  • Protocol inspection
  • Content matching (via signatures)
  • Detection of known attacks (buffer overflows, stealth port scans, etc.)
  • Can be used in inline mode for active prevention

๐Ÿ› ๏ธ Prerequisites for Installing Snort

Before installing Snort, ensure you have:

RequirementDescription
Operating SystemLinux (Ubuntu, CentOS, etc.) recommended
HardwareAt least 2GB RAM, 1 CPU core (more for high-traffic environments)
Network InterfaceIn promiscuous mode or mirrored port (for passive monitoring)
Tools Installedlibpcap-dev,bison,flex,gcc,make,libnetfilter-queue-dev(for IPS)

๐Ÿ“ฆ Installation Steps (Ubuntu Example)

Step 1: Install Dependencies

sudo apt update

sudo apt install -y build-essential libpcap-dev libpcre3-dev libssl-dev pkg-config

Step 2: Download and Install Snort

You can install from source or use packages. Here’s building from source:

cd /tmp

wget https://www.snort.org/downloads/snort/daq-2.0.7.tar.gz

wget https://www.snort.org/downloads/snort/snort-2.9.20.tar.gz

tar -xvzf daq-2.0.7.tar.gz

cd daq-2.0.7

./configure && make && sudo make install

cd ..

tar -xvzf snort-2.9.20.tar.gz

cd snort-2.9.20

./configure –enable-sourcefire && make && sudo make install

Step 3: Set Up Configuration Files

sudo mkdir -p /etc/snort /etc/snort/rules

sudo cp etc/*.conf* /etc/snort

sudo cp etc/schema.sql /etc/snort

Step 4: Configure Basic Rules

Edit /etc/snort/snort.conf:

  • Set HOME_NET to your internal network range
  • Set EXTERNAL_NET to !$HOME_NET
  • Point to local rule files:bash1include $RULE_PATH/local.rules

Create a basic test rule in /etc/snort/rules/local.rules:

alert tcp any any -> $HOME_NET80 (msg:”HTTP Traffic Detected”; sid:1000001; rev:1;)


๐Ÿงช Run Snort in IDS Mode

To test Snort in detection-only mode:

sudo snort -A console -c /etc/snort/snort.conf -i eth0

This will print alerts to the console whenever HTTP traffic is detected.


๐Ÿ”’ Enable Intrusion Prevention (IPS Mode)

To drop malicious traffic in real-time, run Snort in inline mode using NFQUEUE :

Step 1: Set up iptables redirect

sudo iptables -I FORWARD -j NFQUEUE –queue-num 0

Step 2: Run Snort in Inline Mode

sudo snort -Q -c /etc/snort/snort.conf -i eth0

Make sure you have rules with drop actions instead of alert.

Example drop rule:

drop tcp any any -> $HOME_NET23 (msg:”Blocking Telnet”; sid:1000002; rev:1;)


๐Ÿ“š Rule Management

Snort uses rules to detect threats. You can manage rules via:

1. Community Rules

2. Snort Subscriber Rules

  • Paid subscription with faster updates and more coverage

3. Custom Rules

Write your own based on network behavior and policies.

Tip: Use tools like PulledPork to automate rule updates.


๐Ÿ“Š Logging & Alerting

By default, Snort logs to /var/log/snort. You can configure it to log to:

  • Database : MySQL, PostgreSQL (use Barnyard2 or Suricata for processing)
  • SIEM Integration : Forward logs to Splunk, ELK Stack, Graylog, etc.
  • Syslog : Send alerts to centralized logging systems

๐Ÿงฐ Additional Tools for Better Visibility

ToolPurpose
Barnyard2Processes unified2 binary logs into databases or syslog
SuricataAlternative NIDS with similar syntax and features
Snorby / ELSA / SquertWeb-based dashboards for Snort alerts
ELK StackCentralized log analysis and visualization

๐Ÿงฉ Integration with Other Security Systems

  • Firewalls : Integrate with iptables, nftables, or PF for automated blocking
  • SOAR Platforms : Trigger workflows on alert
  • Threat Intelligence Feeds : Import IP/domain blacklists into Snort rules
  • OpenZiti Integration (Bonus) :
    • Use Snort to monitor Ziti overlay network traffic for anomalies
    • Deploy Snort at edge routers where Ziti connects external clients

โœ… Best Practices for Securing Your Network with Snort

  1. Use Layered Defense : Combine Snort with firewalls, endpoint protection, and SIEMs.
  2. Keep Rules Updated : Regularly fetch new threat intelligence rules.
  3. Monitor Logs Daily : Use automation and dashboards to spot trends.
  4. Tune Rules : Reduce false positives by customizing rules to your environment.
  5. Run in Test Mode First : Start with IDS before enabling IPS/drop rules.
  6. Secure Snort Itself : Protect Snort hosts with strong access controls.

๐Ÿ“„ Sample Output (Alert)

[**] [1:1000001:1] HTTP Traffic Detected [**]

[Priority: 0]

04/05-10:20:12.345678 192.168.1.100:54321 -> 192.168.1.200:80

TCP TTL:64 TOS:0x0 ID:54321 IpLen:20 DgmLen:1500 DF

***AP*** Seq: 0x12345678 Ack: 0x87654321 Win: 0x3FD TcpLen: 20


๐Ÿ“Œ Summary Checklist

TaskStatus
Install Snortโœ…
Configure Interfacesโœ…
Set Up Rulesโœ…
Choose IDS or IPS Modeโœ…
Enable Loggingโœ…
Integrate with SIEM or Dashboardโœ…
Schedule Rule Updatesโœ…

Scroll to Top