How To Install Snort on Ubuntu

Snort is an open-source network monitor that not only detects any network intrusion but also prevents it by using its rule-based detection system and real-time traffic analysis. So, if you are thinking of carrying out security measures like real-time threat detection, and intrusion prevention, or want to improve visibility into your network traffic for Ubuntu, try the Snort. This guide will discuss several ways to install Snort on Ubuntu.

3- Ways To Install Snort on Ubuntu

Snort under the rule-based detection system uses three different techniques which include signature-matching, protocol, and anomaly detection. Further, Snort can log the detected events and network traffic for later analysis. These logs can be valuable for forensic investigations in case of a security incident, helping to understand the attack nature and identify the attackers. To install Snort on Ubuntu there are three ways and to demonstrate each method I will be using Ubuntu 24.04:

1: Through Ubuntu Default Package Installer

The first method to install Snort is using the apt package manager as installing applications via apt on Debian-based Linux distributions is an easy way out. In the case of Snort, the apt app installer installs the older version so to install it execute:

sudo apt install snort

Installing Snort On Ubuntu via apt package manager

Next, the installer will ask about the system IP address so to prompt the addition select OK:

Snort IP configuration while installing it on Ubuntu

Next, enter your Ubuntu IP address and select OK to proceed, to get the IP address simply execute the ip a command in the terminal:

Entering Ubuntu IP address while installing it On Ubuntu via apt

Once the installation is complete, you can validate it by checking the Snort version by using the below command:

snort --version

Here, you can see the version installed is 2.9 but officially the version 3.3.0 is already released:

Checking Snort Version to validate its installation via apt

2: Through Snort Source File

The next method for installing Snort is using its source file however, this method is quite lengthy but easy to follow. Using the source file you can install the Snort latest version, for that first you need to install the data acquisition library for Snort. Snort uses it for packet capture and analysis, which are crucial functionalities for its operation.

The libdaq is not available in the apt repository so you have to use its source file which you can download from Snort download page:

Downloading data acquisition library on Ubuntu to install Snort via its source file.

Next, extract the tar file for the data acquisition library using the tar utility:

sudo tar xvzf snort3-libdaq-v3.0.15-0-g1b20345.tar.gz

Extracting libdaq library tar file on Ubuntu to install Snort via its source file.

Now, navigate to the extracted folder and then launch the bootstrap file which will create a configuration for libdaq:

sudo ./bootstrap

Executing the bootstrap file to build the libdaq setup file on Ubuntu

Once the process is completed execute the configuration file to check for all the required dependencies for the libdaq:

sudo ./configure

Executing the configuration file of data acquisition library libdaq on Ubuntu for snort installation

Next, create the make file for libdaq by using the make command:

sudo make

Creating a make file for libdaq on Ubuntu for Snort installation via its source file.

Now, install this data acquisition library for Snort using its make file on Ubuntu:

sudo make install

Installing libdaq on Ubuntu through its make file for Snort

Once the installation is completed now download the tar file for Snort 3.0 on Ubuntu from its official download page:

Downloading Snort source file on Ubuntu through its official site

Alternatively, you can download the Snort file via the terminal as well by using the file download link as in the command below:

wget https://codeload.github.com/snort3/snort3/legacy.tar.gz/refs/tags/3.3.0.0

Downloading Snort source file on Ubuntu through its download link

Next, extract the downloaded file using the tar utility as in the command below:

sudo tar xvzf snort3-snort3-3.3.0.0-0-g33657f3.tar.gz

Extracting Snort source file on Ubuntu

To install Snort 3.0 on Ubuntu you need to install multiple libraries otherwise, you may encounter multiple errors while installation, so here are some libraries you need to install:

sudo apt install build-essential libpcap-dev libpcre3-dev libnet1-dev zlib1g-dev luajit hwloc libdumbnet-dev bison flex liblzma-dev openssl libssl-dev pkg-config libhwloc-dev cmake cpputest libsqlite3-dev uuid-dev libcmocka-dev libnetfilter-queue-dev libmnl-dev autotools-dev libluajit-5.1-dev libunwind-dev

Installing necessary libraries for installing Snort on Ubuntu

Here, is another library named libgoogle-preftools-dev which is primarily used for performance analysis so you also need to install it as well:

Installing Google library for performance analysis to install Snort on Ubuntu

After installing all the necessary libraries execute the configuration file:

sudo ./configure_cmake.sh

Executing the configuration file for Snort source file on Ubuntu

As a result of the configuration file execution, a new directory named build will be created that will contain all the necessary files for Snort installation:

cd build

Navigating to the build directory of snort created after executing its configuration file on Ubuntu

Now install Snort on Ubuntu using its make file by executing the following command:

sudo make install

Installing Snort on Ubuntu via its source file

The process will take a significant amount of time and once it is completed you will see the message of the build target at the end as in the image below:

Snort installation completion message on Ubuntu

Snort on Ubuntu is installed in the local directory in usr folder, so to use it you need to navigate to it and then execute the lidconfig command to maintain the dynamic linker cache, ensuring the efficient execution of programs that rely on shared libraries:

cd /usr/local/snort/bin
sudo ldconfig

maintaining the dynamic linker cache, ensuring the efficient execution of programs on Ubuntu for Snort

Next, you can check the version of Snort to validate its installation on Ubuntu:

./snort -V

Checking Snort version on Ubuntu installed via Snort Source file

Accessing Snort by manually navigating to its directory can be a tiresome process, so to avoid that you can create a symbolic link of the directory as well to sbin directory:

sudo ln -s /usr/local/bin/snort /usr/sbin/snort

3: Through apt-get Command

The third and last way for installing Snort on Ubuntu is using the apt-get command, the primary difference between apt install is that apt-get is a full-featured package management. So to install Snort execute:

sudo apt-get install snort

Installing Snort on Ubuntu using the apt-get utility

Once the installation is completed, you can check the installation version of Snort:

snort -V

Checking Snort version on Ubuntu Installed via apt-get utility

Finally, you can test if the configuration file of Snort is working correctly by executing the below command:

sudo snort -T -c /etc/snort/snort.conf

testing Snort configuration file on Ubuntu

Once the test is completed without any errors, you will see the message of Snort successfully validated the configuration:

successfully validated Snort configuration on Ubuntu

Conclusion

To install Snort on Ubuntu, there are primarily three ways discussed in this guide, these include using apt install, apt-get install, and using Snort source file. However, if you need to install the latest version of Snort then use its source file because the other two no doubt are easy ones but they install the older version of Snort.

 

Index
Scroll to Top