Exploring the latest version of Snort
Installing the Snort and the DAQ Library
To install Snort and the DAQ library from source, download the tarballs from the Snort website:
wget https://www.snort.org/downloads/snort/daq-2.0.2.tar.gz wget https://www.snort.org/downloads/snort/snort-2.9.6.2.tar.gz
Once you have downloaded, uncompressed, and unpacked the tarballs, install them with the usual sequence:
./configure; make; sudo make install
Many Linux distros also let you install Snort packages directly through the package manager, but be aware that the package version might not be the latest version of Snort.
Downloading Community Rules
Use the wget command to download community rules. Then, simply unpack and install the rules:
wget https://www.snort.org/rules/community tar -xvfz community.tar.gz -C /etc/snort/rules
You can use open community rules or create your own. It is also possible to use registered and subscriber rules. To use these rules, however, you must be a paying customer. Once you have logged in and subscribed, you can then obtain the rules as shown in Listing 1.
Listing 1
Obtaining Snort Rules
Creating an IPS
Snort and DAQ use the PCAP API by default. If you run Snort without any arguments, DAQ uses PCAP. If you're interested in just doing a bit of passive listening to the network and having Snort issue alerts, the default setting will work for you. If, however, you want to use Snort on a Linux system to act as an IPS, you need a system with at least two interfaces. You then need to run Snort in what is called inline mode, which means you are using Snort and AFPacket to capture and log network packets, then using Netfilter (iptables) to drop suspect traffic.
I suggest three interfaces, as shown in Figure 1. Interface 1 receives traffic into your Linux system from your network. Then, Snort and AFPacket/DAQ capture traffic and forward it to netfilter/iptables. The IPS-filtered traffic is then sent back out on the network using Interface 2. Interface 3, which is not used to filter traffic, is a separate NIC that allows you to send out logging information. You can also use Interface 3 for command and control of the system. I would much rather have dedicated interfaces monitoring and blocking traffic; if I want to administer the system, I can connect via SSH or another remote access tool via Interface 3.
![](/var/linux_magazin/storage/images/issues/2014/167/the-new-snort/figure-1/624745-1-eng-US/Figure-1_large.png)
If you want to run AFPacket in inline mode, you must set the device to one or more interface pairs, where each member of a pair is separated by a single colon and each pair is separated by a double colon. You don't need to configure a queue or bridge with AFPacket. Still, you will need to direct Snort to use the correct interfaces. The syntax for creating pairs is as follows:
To connect Interfaces 1 and 2:
eth0:eth1
To connect four interfaces:
eth0:eth1::eth2:eth3
Make sure all interfaces are in promiscuous mode, and run Snort inline as follows:
$ sudo snort --daq afpacket -i eth1:eth2 -Q -c snort.conf
As of this writing, AFPacket will allocate a 128MB packet memory buffer. If that buffer is too small, you can increase it with the buffer_size_mb daq-var
value.
Once you have Snort running in inline mode with AFPacket, it is possible to blacklist traffic by combining Snort with netfilter/iptables. For example, the command sequence below will start Snort and use iptables to drop traffic. First, make sure that the nfque
module is installed on your Linux system. Then, run Snort in inline mode at the command line:
$ sudo snort -c snort.conf -i eth1:eth2 -Q --daq afpacket \ --daq -mode inline -daq -var buffer_size_mb=1024
Of course, it is also possible to run Snort against the properly configured snort.conf
file. From within snort.conf
, enter the following lines:
config policy_mode:inline config daq: afpacket config daq_mode: inline config daq_var: buffer_size_mb=1024
Once in inline mode, you can then create an iptables filter to drop the traffic:
iptables -A INPUT -p tcp --dport 110 -j NFQUEUE --queue-num 2
Now, all unencrypted POP3 traffic is dropped. It is also possible to set Snort and iptables to drop additional TCP-based traffic, including NetBios:
iptables -A INPUT -p tcp --dport 139 -j NFQUEUE --queue-num 2
Now, all TCP-based traffic at port 139 is dropped. You can also log this traffic and send alerts when a packet is blocked.
« Previous 1 2 3 4 Next »
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
![Learn More](https://www.linux-magazine.com/var/linux_magazin/storage/images/media/linux-magazine-eng-us/images/misc/learn-more/834592-1-eng-US/Learn-More_medium.png)
News
-
NVIDIA Released Driver for Upcoming NVIDIA 560 GPU for Linux
Not only has NVIDIA released the driver for its upcoming CPU series, it's the first release that defaults to using open-source GPU kernel modules.
-
OpenMandriva Lx 24.07 Released
If you’re into rolling release Linux distributions, OpenMandriva ROME has a new snapshot with a new kernel.
-
Kernel 6.10 Available for General Usage
Linus Torvalds has released the 6.10 kernel and it includes significant performance increases for Intel Core hybrid systems and more.
-
TUXEDO Computers Releases InfinityBook Pro 14 Gen9 Laptop
Sporting either AMD or Intel CPUs, the TUXEDO InfinityBook Pro 14 is an extremely compact, lightweight, sturdy powerhouse.
-
Google Extends Support for Linux Kernels Used for Android
Because the LTS Linux kernel releases are so important to Android, Google has decided to extend the support period beyond that offered by the kernel development team.
-
Linux Mint 22 Stable Delayed
If you're anxious about getting your hands on the stable release of Linux Mint 22, it looks as if you're going to have to wait a bit longer.
-
Nitrux 3.5.1 Available for Install
The latest version of the immutable, systemd-free distribution includes an updated kernel and NVIDIA driver.
-
Debian 12.6 Released with Plenty of Bug Fixes and Updates
The sixth update to Debian "Bookworm" is all about security mitigations and making adjustments for some "serious problems."
-
Canonical Offers 12-Year LTS for Open Source Docker Images
Canonical is expanding its LTS offering to reach beyond the DEB packages with a new distro-less Docker image.
-
Plasma Desktop 6.1 Released with Several Enhancements
If you're a fan of Plasma Desktop, you should be excited about this new point release.