How To Install Snort NIDS On Ubuntu Linux
How To Install Snort NIDS On Ubuntu Linux
How To Install Snort NIDS On Ubuntu Linux
Synopsis
Security is a major issue in today’s enterprise environments. There are lots of tools
available to secure network infrastructure and communication over the internet.
Snort is a free and open source lightweight network intrusion detection and
prevention system. Snort is the most widely-used NIDS (Network Intrusion and
Detection System) that detects and prevent intrusions by searching protocol, content
analysis, and various pre-processors. Snort provides a wealth of features, like buffer
overflow, stealth port scans, and CGI attacks, just to name a few. Snort tries to
detect malicious activity, denial of service attacks, and port scans by monitoring
network traffic. It's divided into five major components: Packet decoder,
Preprocessor, Detection engine, Logging and Alerting system, and Output modules.
Here, we will explain how to install from source, create a configuration file for Snort,
create sample rules, and finally test on Ubuntu 16.04.
System Requirements
Newly deployed Ubuntu 16.04 server.
First, log in to root user and update your system by running the following command:
apt-get update -y
apt-get upgrade -y
https://blog.rapid7.com/2017/01/11/how-to-install-snort-nids-on-ubuntu-linux/ 1/9
5/9/2019 How to Install Snort NIDS on Ubuntu Linux
Before installing Snort, you will need to install required dependencies on your
system.
You will also need to install DAQ. To do this, first download the latest version of DAQ
with the following command:
wget https://www.snort.org/downloads/snort/daq-2.0.6.tar.gz
Once the download is completed, extract the downloaded file with the following
command:
cd daq-2.0.6
https://blog.rapid7.com/2017/01/11/how-to-install-snort-nids-on-ubuntu-linux/ 2/9
5/9/2019 How to Install Snort NIDS on Ubuntu Linux
First, download the latest version of the Snort source code with the following
command:
wget https://www.snort.org/downloads/snort/snort-2.9.8.3.tar.gz
Once the download is completed, extract the downloaded file with the following
command:
cd snort-2.9.8.3
Next, you will need to update the shared libraries, otherwise you will get an error
when you try to run Snort:
ldconfig
ln -s /usr/local/bin/snort /usr/sbin/snort
Finally, you can verify the installation and configuration with the following command:
snort -V
https://blog.rapid7.com/2017/01/11/how-to-install-snort-nids-on-ubuntu-linux/ 3/9
5/9/2019 How to Install Snort NIDS on Ubuntu Linux
Configure Snort
You can configure Snort in three modes: Sniffer mode, Packet logger mode, and
Network IDS mode. Here, we will configure Snort for Network IDS Mode.
Before configuring Snort, you will need to create a directory structure for Snort.
mkdir /etc/snort
mkdir /etc/snort/preproc_rules
mkdir /etc/snort/rules
mkdir /var/log/snort
mkdir /usr/local/lib/snort_dynamicrules
touch /etc/snort/rules/white_list.rules
touch /etc/snort/rules/black_list.rules
touch /etc/snort/rules/local.rules
Next, you will need to copy configuration files from Nnort source:
https://blog.rapid7.com/2017/01/11/how-to-install-snort-nids-on-ubuntu-linux/ 4/9
5/9/2019 How to Install Snort NIDS on Ubuntu Linux
cd snort-2.9.8.3
Then, copy .conf , .map and .dtd files to the /etc/snort/ directory:
cp -avr src/dynamic-preprocessors/build/usr/local/lib/snort_dynamicpreprocesso
Now we will edit the Snort configuration file. First, comment out all rulesets with the
following command:
nano /etc/snort/snort.conf
https://blog.rapid7.com/2017/01/11/how-to-install-snort-nids-on-ubuntu-linux/ 5/9
5/9/2019 How to Install Snort NIDS on Ubuntu Linux
Testing Snort
Snort is now ready for testing—but before starting, you will need to create a rule set.
nano /etc/snort/rules/local.rules
https://blog.rapid7.com/2017/01/11/how-to-install-snort-nids-on-ubuntu-linux/ 6/9
5/9/2019 How to Install Snort NIDS on Ubuntu Linux
alert tcp any any -> $HOME_NET 21 (msg:"FTP connection attempt"; sid:1000001;
alert icmp any any -> $HOME_NET any (msg:"ICMP connection attempt"; sid:10000
alert tcp any any -> $HOME_NET 80 (msg:"TELNET connection attempt"; sid:10000
The above rules will generate an alert when someone tries to Ping, FTP, or Telnet to
the server.
Now start Snort in Network IDS mode from the terminal and tell it to output any alert
to the console:
Now, since Snort is up and listening on interface eth0 , so let’s try to Ping, FTP, and
Telnet from remote machine.
ping 192.168.15.189
ftp 192.168.15.189
telnet 192.168.15.189 80
On the Snort server, you should see the output something like this:
https://blog.rapid7.com/2017/01/11/how-to-install-snort-nids-on-ubuntu-linux/ 7/9
5/9/2019 How to Install Snort NIDS on Ubuntu Linux
You can stop Snort at any time by pressing Ctrl+c from your keyboard.
nano /lib/systemd/system/snort.service
[Unit]
Description=Snort NIDS Daemon
After=syslog.target network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/snort -q -c /etc/snort/snort.conf -i eth0
[Install]
WantedBy=multi-user.target
Save the file, then enable the script to run at boot time:
You can check the status of Snort by running the following command:
https://blog.rapid7.com/2017/01/11/how-to-install-snort-nids-on-ubuntu-linux/ 8/9
5/9/2019 How to Install Snort NIDS on Ubuntu Linux
References
Install Snort
Snort Rules
https://blog.rapid7.com/2017/01/11/how-to-install-snort-nids-on-ubuntu-linux/ 9/9