{"id":6764,"date":"2020-08-23T00:14:20","date_gmt":"2020-08-22T21:14:20","guid":{"rendered":"https:\/\/kifarunix.com\/?p=6764"},"modified":"2024-03-14T22:24:08","modified_gmt":"2024-03-14T19:24:08","slug":"install-and-configure-snort-3-nids-on-ubuntu-20-04","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-and-configure-snort-3-nids-on-ubuntu-20-04\/","title":{"rendered":"Install and Configure Snort 3 NIDS on Ubuntu 20.04"},"content":{"rendered":"\n
In this tutorial, you will learn how to install and configure Snort 3 NIDS on Ubuntu 20.04. Snort<\/a> is a lightweight network intrusion detection system. It features rules-based logging and can perform content searching\/matching in addition to detecting a variety of other attacks and probes, such as buffer overflows, stealth port scans, CGI attacks, SMB probes, and much more. Snort has a real-time alerting capability, with alerts being sent to Some of the Snort 3 features include;<\/p>\n\n\n\n As of this writing, Ubuntu 20.04 provides snort 2.9 on its default Universe repos;<\/p>\n\n\n\n In order to install Snort 3 NIDS, you need to build it from the source.<\/p>\n\n\n\n To begin with, run system package cache update;<\/p>\n\n\n\n For a successful build and installation of Snort 3 on Ubuntu 20.04, there are a number of build tools and dependencies that needs to be installed prior to the build process as outlined on the Dependencies page<\/a>. <\/p>\n\n\n\n Download and install latest version of the Snort DAQ (Data Acquisition<\/em> library) . DAQ is not available on the default Ubuntu repos and hence, you need to build and install it from the source;<\/p>\n\n\n\n Download and install google\u2019s thread-caching malloc, Tcmalloc, a memory allocator optimized for high concurrency situations which will provide better speed for the trade-off of higher memory usage. This is an optional dependency but highly recommended.<\/p>\n\n\n\n Now that we have all required dependencies in place, download<\/a> and install Snort 3 on Ubuntu 20.04;<\/p>\n\n\n\n Extract and navigate to Snort 3 source directory, compile and install it;<\/p>\n\n\n\n Navigate to the build directory and compile and install Snort 3 on Ubuntu 20.04;<\/p>\n\n\n\n Once the installation completes, update shared libraries;<\/p>\n\n\n\n Verify Snort 3 Installation by checking the version;<\/p>\n\n\n\n The above confirms that Snort 3 installation is successful and is working fine.<\/p>\n\n\n\n To obtain Snort command line help, simply execute either of the commands below and check the difference;<\/p>\n\n\n\n First off, put the interface on which Snort is listening for network traffic on Verify;<\/p>\n\n\n\n Disable Interface Offloading to prevent Snort from truncating large packets larger than 1518 bytes. You can check if this feature is enabled;<\/p>\n\n\n\n GRO is enabled while LRO is fixed and hence cannot be changed.<\/p>\n\n\n\n Then disable;<\/p>\n\n\n\n The two NIC changes are temporary. To ensure the changes persists across system reboot, create and enable a systemd service unit to implement the changes;<\/p>\n\n\n\n Reload systemd configuration settings;<\/p>\n\n\n\n Start and enable the service on boot;<\/p>\n\n\n\n Rulesets is the main artery for Snorts intrusion detection engine. There are three types of Snort Rules:<\/p>\n\n\n\n In this tutorial, we will install the community Snort rules;<\/p>\n\n\n\n Create Snort Rules directory. In the Download Snort 3 community rules from Snort 3 downloads page<\/a>;<\/p>\n\n\n\n Extract the rules and store them on Snort rules directory;<\/p>\n\n\n\n Now that we have the rules to get us started in place, you need to configure Snort 3. Open the main configuration file for editing;<\/p>\n\n\n\n Set the networks to protect against attacks as the value for the Edit Snort condif in the Under IPS section, define the location to your rules;<\/p>\n\n\n\n Save and exit the configuration file.<\/p>\n\n\n\n OpenAppID is an application layer plugin that enables Snort to detect various applications, Facebook, Netflix, Twitter, and Reddit, used in the network. Run the commands below download from Snort 3 downloads page<\/a> and install Snort OpenAppID;<\/p>\n\n\n\n Next, edit the Snort 3 configuration file and define the location of the OpenAppID libraries;<\/p>\n\n\n\n Save and exit the configuration file.<\/p>\n\n\n\n Create Snorts Log directory;<\/p>\n\n\n\n Next, run syntax checking;<\/p>\n\n\n\n Create Custom local rules for the purposes of testing our Snort setup.<\/p>\n\n\n\n Create a rule to detect ping tests;<\/p>\n\n\n\n Save and exit the local rules file. Check the syntax;<\/p>\n\n\n\n Next, run the test by executing the command below;<\/p>\n\n\n\n On another terminal, ping your Snort server. While the ping runs, you should see the alert lines written to standard output;<\/p>\n\n\n\n To write Snort 3 events to log files, you need to enable configure alert settings. There are different Snort logging options that are explained well in the Snort 3 manual, Logger Modules section<\/a>. To output the event data to a file, in brief format (as defined in the command line above by option The setting will cause snort to write logs to Run the command again, this time, without the option, Run the ping test again. If you check on the logs directory, you should see an You can include the local rules in snort.lua;<\/p>\n\n\n\n While it is possible to run Snort as a daemon in the background with command line option If you are going to run Snort as a service, it is prudent to run it a non privileged system user. Hence, create a non login system user account for Snort;<\/p>\n\n\n\n Create a systemd service unit for Snort to be run as snort user. Adjust your interfaces accordingly.<\/p>\n\n\n\n Reload systemd configs;<\/p>\n\n\n\n Set the ownership and permissions on the log file;<\/p>\n\n\n\n Start and enable Snort to run on system boot. The service will run as root and then drop the privileges to Snort user created.<\/p>\n\n\n\n Check the service to confirm if it is running;<\/p>\n\n\n\n Note that we have just scratched the service on what the configuration and what Snort 3 is capable of.<\/strong><\/p>\n\n\n\n Snort 3 Installation<\/a><\/p>\n\n\n\n Snort 3 User Manual<\/a><\/p>\n\n\n\n Install and Configure AIDE on Ubuntu 20.04<\/a><\/p>\n\n\n\n Install and Configure Tripwire Security Monitoring tool on CentOS 8<\/a><\/p>\n\n\n\n
syslog, a separate “alert” file, or even to a Windows computer via Samba.<\/p>\n\n\n\n\n
Installing Snort 3 NIDS on Ubuntu 20.04<\/h2>\n\n\n\n
apt show snort<\/code><\/pre>\n\n\n\n
\nPackage: snort\nVersion: 2.9.7.0-5build1\nPriority: optional\nSection: universe\/net\nOrigin: Ubuntu\nMaintainer: Ubuntu Developers
Build and Install Snort 3 from Source Code on Ubuntu 20.04<\/h3>\n\n\n\n
Run System Update<\/h4>\n\n\n\n
apt update<\/code><\/pre>\n\n\n\n
apt upgrade<\/code><\/pre>\n\n\n\n
Install Required Build Tools<\/h4>\n\n\n\n
apt install build-essential libpcap-dev libpcre3-dev libnet1-dev zlib1g-dev luajit hwloc libdnet-dev 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<\/code><\/pre>\n\n\n\n
mkdir snort-source-files\ncd snort-source-files<\/code><\/pre>\n\n\n\n
git clone https:\/\/github.com\/snort3\/libdaq.git\ncd libdaq\n.\/bootstrap\n.\/configure\nmake\nmake install\n<\/code><\/pre>\n\n\n\n
cd ..\/\nwget wget https:\/\/github.com\/gperftools\/gperftools\/releases\/download\/gperftools-2.9.1\/gperftools-2.9.1.tar.gz\ntar xzf gperftools-2.9.1.tar.gz\ncd gperftools-2.8\/\n.\/configure\nmake\nmake install\n<\/code><\/pre>\n\n\n\n
Install Snort 3 from Source Code on Ubuntu 20.04<\/h4>\n\n\n\n
cd ..\/\nwget https:\/\/github.com\/snort3\/snort3\/archive\/refs\/tags\/3.1.28.0.tar.gz<\/code><\/pre>\n\n\n\n
tar xzf 3.1.28.0.tar.gz<\/code><\/pre>\n\n\n\n
cd snort3-3.1.28.0<\/code><\/pre>\n\n\n\n
.\/configure_cmake.sh --prefix=\/usr\/local --enable-tcmalloc<\/code><\/pre>\n\n\n\n
...\n-------------------------------------------------------\nsnort version 3.0.2\n\nInstall options:\n prefix: \/usr\/local\n includes: \/usr\/local\/include\/snort\n plugins: \/usr\/local\/lib\/snort\n\nCompiler options:\n CC: \/usr\/bin\/cc\n CXX: \/usr\/bin\/c++\n CFLAGS: -fvisibility=hidden -DNDEBUG -g -ggdb -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free \n CXXFLAGS: -fvisibility=hidden -DNDEBUG -g -ggdb -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free \n EXE_LDFLAGS: \n MODULE_LDFLAGS: \n\nFeature options:\n DAQ Modules: Static (afpacket;bpf;dump;fst;nfq;pcap;trace)\n Flatbuffers: OFF\n Hyperscan: OFF\n ICONV: ON\n Libunwind: ON\n LZMA: ON\n RPC DB: Built-in\n SafeC: OFF\n TCMalloc: ON\n UUID: ON\n-------------------------------------------------------\n\n-- Configuring done\n-- Generating done\n-- Build files have been written to: \/root\/snort-source-files\/snort3\/build\n<\/code><\/pre>\n\n\n\n
cd build\nmake\nmake install<\/code><\/pre>\n\n\n\n
ldconfig<\/code><\/pre>\n\n\n\n
snort -V<\/code><\/pre>\n\n\n\n
\n ,,_ -*> Snort++ <*-\n o\" )~ Version 3.1.28.0\n '''' By Martin Roesch & The Snort Team\n http:\/\/snort.org\/contact#team\n Copyright (C) 2014-2022 Cisco and\/or its affiliates. All rights reserved.\n Copyright (C) 1998-2013 Sourcefire, Inc., et al.\n Using DAQ version 3.0.6\n Using LuaJIT version 2.1.0-beta3\n Using OpenSSL 3.0.2 15 Mar 2022\n Using libpcap version 1.10.1 (with TPACKET_V3)\n Using PCRE version 8.39 2016-06-14\n Using ZLIB version 1.2.11\n Using LZMA version 5.2.5\n<\/code><\/pre>\n\n\n\n
Obtaining Snort Command Line Help<\/h3>\n\n\n\n
snort --help<\/code><\/pre>\n\n\n\n
snort -?<\/code><\/pre>\n\n\n\n
-? <option prefix> output matching command line option quick help (same as --help-options) (optional)\n-A <mode> set alert mode: none, cmg, or alert_*\n-B <mask> obfuscated IP addresses in alerts and packet dumps using CIDR mask\n-C print out payloads with character data only (no hex)\n-c <conf> use this configuration\n-D run Snort in background (daemon) mode\n-d dump the Application Layer\n-e display the second layer header info\n-f turn off fflush() calls after binary log writes\n-G <0xid> (same as --logid) (0:65535)\n-g <gname> run snort gid as <gname> group (or gid) after initialization\n-H make hash tables deterministic\n-i <iface>... list of interfaces\n-k <mode> checksum mode; default is all (all|noip|notcp|noudp|noicmp|none)\n-L <mode> logging mode (none, dump, pcap, or log_*)\n-l <logdir> log to this directory instead of current directory\n-M log messages to syslog (not alerts)\n-m <umask> set the process file mode creation mask (0x000:0x1FF)\n-n <count> stop after count packets (0:max53)\n-O obfuscate the logged IP addresses\n-Q enable inline mode operation\n-q quiet mode - suppress normal logging on stdout\n-R <rules> include this rules file in the default policy\n-r <pcap>... (same as --pcap-list)\n-S <x=v> set config variable x equal to value v\n-s <snap> (same as --snaplen); default is 1518 (68:65535)\n-T test and report on the current Snort configuration\n-t <dir> chroots process to <dir> after initialization\n-U use UTC for timestamps\n-u <uname> run snort as <uname> or <uid> after initialization\n-V (same as --version)\n-v be verbose\n-X dump the raw packet data starting at the link layer\n-x same as --pedantic\n-y include year in timestamp in the alert and log files\n-z <count> maximum number of packet threads (same as --max-packet-threads); 0 gets the number of CPU cores reported by the system; default is 1 (0:max32)\n...\n<\/code><\/pre>\n\n\n\n
Configuring Snort 3 NIDS on Ubuntu 20.04<\/h3>\n\n\n\n
Configure Network Interface Cards<\/h4>\n\n\n\n
promiscuous<\/code> mode so that it can be able to see all of the network traffic sent to it rather than seeing only the traffic originating from within the Snort 3 server alone.<\/p>\n\n\n\n
ip link set dev enp0s8 promisc on<\/code><\/pre>\n\n\n\n
ip add sh enp0s8<\/code><\/pre>\n\n\n\n
3: enp0s8: <BROADCAST,MULTICAST,PROMISC<\/strong>,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000\n link\/ether 08:00:27:7f:84:15 brd ff:ff:ff:ff:ff:ff\n inet 192.168.57.3\/24 brd 192.168.57.255 scope global dynamic enp0s8\n valid_lft 446sec preferred_lft 446sec\n inet6 fe80::a00:27ff:fe7f:8415\/64 scope link \n valid_lft forever preferred_lft forever<\/code><\/pre>\n\n\n\n
ethtool -k enp0s8 | grep receive-offload<\/code><\/pre>\n\n\n\n
generic-receive-offload: on\nlarge-receive-offload: off [fixed]<\/code><\/pre>\n\n\n\n
ethtool -K enp0s8 gro off lro off<\/code><\/pre>\n\n\n\n
vim \/etc\/systemd\/system\/snort3-nic.service<\/code><\/pre>\n\n\n\n
[Unit]\nDescription=Set Snort 3 NIC in promiscuous mode and Disable GRO, LRO on boot\nAfter=network.target\n\n[Service]\nType=oneshot\nExecStart=\/usr\/sbin\/ip link set dev enp0s8 promisc on\nExecStart=\/usr\/sbin\/ethtool -K enp0s8 gro off lro off\nTimeoutStartSec=0\nRemainAfterExit=yes\n\n[Install]\nWantedBy=default.target\n<\/code><\/pre>\n\n\n\n
systemctl daemon-reload<\/code><\/pre>\n\n\n\n
systemctl enable --now snort3-nic.service<\/code><\/pre>\n\n\n\n
Install Snort 3 Rulesets on Ubuntu 20.04<\/h4>\n\n\n\n
\n
\/usr\/local\/etc\/snort\/snort_defaults.lua<\/code><\/strong> config file, the default rules path (RULE_PATH), is defined as
\/usr\/local\/etc\/rules<\/strong><\/code>.<\/p>\n\n\n\n
mkdir \/usr\/local\/etc\/rules<\/code><\/pre>\n\n\n\n
wget https:\/\/www.snort.org\/downloads\/community\/snort3-community-rules.tar.gz<\/code><\/pre>\n\n\n\n
tar xzf snort3-community-rules.tar.gz -C \/usr\/local\/etc\/rules\/<\/code><\/pre>\n\n\n\n
ls \/usr\/local\/etc\/rules\/snort3-community-rules\/<\/code><\/pre>\n\n\n\n
AUTHORS LICENSE sid-msg.map snort3-community.rules<\/strong> VRT-License.txt<\/code><\/pre>\n\n\n\n
vim \/usr\/local\/etc\/snort\/snort.lua<\/code><\/pre>\n\n\n\n
HOME_NET<\/strong><\/code> variable. For simplicity, i just set this to the subnet of Snort 3 interface. The
EXTERNAL_NET<\/code><\/strong> is anything other than our HOME_NET;<\/p>\n\n\n\n
...\n-- HOME_NET and EXTERNAL_NET must be set now\n-- setup the network addresses you are protecting\nHOME_NET = '192.168.57.3\/32'\n\n-- set up the external network addresses.\n-- (leave as \"any\" in most situations)\n-- EXTERNAL_NET = 'any'\nEXTERNAL_NET = '!$HOME_NET'\n...\n<\/code><\/pre>\n\n\n\n
\/usr\/local\/etc\/snort\/snort.lua<\/strong><\/code> configuration file.<\/p>\n\n\n\n
vim \/usr\/local\/etc\/snort\/snort.lua<\/code><\/pre>\n\n\n\n
\nips =\n{\n -- use this to enable decoder and inspector alerts\n --enable_builtin_rules = true,\n\n -- use include for rules files; be sure to set your path\n -- note that rules files can include other rules files\n variables = default_variables,\n rules = [[ \n include $RULE_PATH\/snort3-community-rules\/snort3-community.rules\n ]]\n}\n...\n<\/code><\/pre>\n\n\n\n
Installing Snort OpenAppID<\/h3>\n\n\n\n
wget https:\/\/snort.org\/downloads\/openappid\/12159 -O OpenAppId-12159.tgz\ntar -xzvf OpenAppId-12159.tgz\ncp -R odp \/usr\/local\/lib\/<\/code><\/pre>\n\n\n\n
vim \/usr\/local\/etc\/snort\/snort.lua<\/code><\/pre>\n\n\n\n
appid =\n{\n -- appid requires this to use appids in rules\n --app_detector_dir = 'directory to load appid detectors from'\n app_detector_dir = '\/usr\/local\/lib',<\/strong>\n
log_stats = true,<\/strong><\/code>\n\n}<\/code><\/pre>\n\n\n\n
mkdir \/var\/log\/snort<\/code><\/pre>\n\n\n\n
snort -c \/usr\/local\/etc\/snort\/snort.lua<\/code><\/pre>\n\n\n\n
...\nFinished \/usr\/local\/etc\/snort\/snort.lua:\nLoading \/usr\/local\/etc\/rules\/snort3-community-rules\/snort3-community.rules:\nFinished \/usr\/local\/etc\/rules\/snort3-community-rules\/snort3-community.rules:\n--------------------------------------------------\nrule counts\n total rules loaded: 829\n text rules: 829\n option chains: 829\n chain headers: 56\n--------------------------------------------------\nport rule counts\n tcp udp icmp ip\n any 63 3 0 0\n src 124 2 0 0\n dst 539 98 0 0\n both 0 1 0 0\n total 726 104 0 0\n--------------------------------------------------\nips policies rule stats\n id loaded shared enabled file\n 0 829 0 829 \/usr\/local\/etc\/snort\/snort.lua\n--------------------------------------------------\nflowbits\n defined: 20\n not checked: 11\n not set: 3\n--------------------------------------------------\nservice rule counts to-srv to-cli\n dns: 89 2\n ftp: 7 2\n ftp-data: 0 8\n http: 489 92\n http2: 489 92\n imap: 0 8\n irc: 4 1\n netbios-ssn: 15 1\n pop3: 0 8\n smtp: 16 0\n ssl: 14 31\n telnet: 1 0\n total: 1124 245\n--------------------------------------------------\nfast pattern port groups src dst any\n packet: 11 24 2\n--------------------------------------------------\nfast pattern service groups to-srv to-cli\n packet: 9 7\n key: 2 0\n header: 2 5\n body: 2 0\n file: 2 5\n method: 2 0\n--------------------------------------------------\nsearch engine\n instances: 70\n patterns: 1715\n pattern chars: 36451\n num states: 27885\n num match states: 1724\n memory scale: KB\n total memory: 785.997\n pattern memory: 102.521\n match list memory: 280.07\n transition memory: 394.656\n--------------------------------------------------\npcap DAQ configured to passive.\n\nSnort successfully validated the configuration (with 0 warnings).\no\")~ Snort exiting\n<\/code><\/pre>\n\n\n\n
vim \/usr\/local\/etc\/rules\/local.rules<\/code><\/pre>\n\n\n\n
alert icmp any any -> $HOME_NET any (msg:\"ICMP connection test\"; sid:1000001; rev:1;)<\/code><\/pre>\n\n\n\n
snort -c \/usr\/local\/etc\/snort\/snort.lua -R \/usr\/local\/etc\/rules\/local.rules<\/code><\/pre>\n\n\n\n
snort -c \/usr\/local\/etc\/snort\/snort.lua -R \/usr\/local\/etc\/rules\/local.rules -i enp0s8 -A alert_fast -s 65535 -k none<\/code><\/pre>\n\n\n\n
...\n--------------------------------------------------\nsearch engine\n instances: 70\n patterns: 1715\n pattern chars: 36451\n num states: 27885\n num match states: 1724\n memory scale: KB\n total memory: 785.997\n pattern memory: 102.521\n match list memory: 280.07\n transition memory: 394.656\n--------------------------------------------------\npcap DAQ configured to passive.\nCommencing packet processing\n++ [0] enp0s8\n08\/22-19:20:23.502536 [**] [1:1000001:1] \"ICMP connection test\" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.57.1 -> 192.168.57.3\n08\/22-19:20:24.526491 [**] [1:1000001:1] \"ICMP connection test\" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.57.1 -> 192.168.57.3\n08\/22-19:20:25.550241 [**] [1:1000001:1] \"ICMP connection test\" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.57.1 -> 192.168.57.3\n08\/22-19:20:26.574652 [**] [1:1000001:1] \"ICMP connection test\" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.57.1 -> 192.168.57.3\n08\/22-19:20:27.598509 [**] [1:1000001:1] \"ICMP connection test\" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.57.1 -> 192.168.57.3\n...\n<\/code><\/pre>\n\n\n\n
Configure Snort 3 Logging<\/h4>\n\n\n\n
-A alert_type<\/strong><\/code>), open the
snort.lua<\/code><\/strong> configuration and head over to the outputs section.<\/p>\n\n\n\n
vim \/usr\/local\/etc\/snort\/snort.lua<\/code><\/pre>\n\n\n\n
---------------------------------------------------------------------------\n-- 7. configure outputs\n---------------------------------------------------------------------------\n\n-- event logging\n-- you can enable with defaults from the command line with -A
alert_fast.txt<\/strong><\/code> file. Save and exit the configuration and run syntax checking.<\/p>\n\n\n\n
snort -c \/usr\/local\/etc\/snort\/snort.lua<\/code><\/pre>\n\n\n\n
-A alert_fast<\/strong><\/code>, but with an option to specify the log directory,
-l \/var\/log\/snort<\/strong><\/code>.<\/p>\n\n\n\n
snort -c \/usr\/local\/etc\/snort\/snort.lua -R \/usr\/local\/etc\/rules\/local.rules -i enp0s8 -s 65535 -k none -l \/var\/log\/snort\/<\/code><\/pre>\n\n\n\n
alert_fast.txt<\/strong><\/code> file created. You can tail this file;<\/p>\n\n\n\n
tail -f \/var\/log\/snort\/alert_fast.txt<\/code><\/pre>\n\n\n\n
08\/22-19:30:41.554941 [**] [1:1000001:1] \"ICMP connection test\" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.57.1 -> 192.168.57.3\n08\/22-19:30:42.578554 [**] [1:1000001:1] \"ICMP connection test\" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.57.1 -> 192.168.57.3\n08\/22-19:30:43.602594 [**] [1:1000001:1] \"ICMP connection test\" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.57.1 -> 192.168.57.3\n08\/22-19:30:44.626660 [**] [1:1000001:1] \"ICMP connection test\" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.57.1 -> 192.168.57.3\n08\/22-19:30:45.650654 [**] [1:1000001:1] \"ICMP connection test\" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.57.1 -> 192.168.57.3\n08\/22-19:30:46.674630 [**] [1:1000001:1] \"ICMP connection test\" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.57.1 -> 192.168.57.3\n...\n<\/code><\/pre>\n\n\n\n
ips =\n{\n -- use this to enable decoder and inspector alerts\n -- enable_builtin_rules = true,\n\n -- use include for rules files; be sure to set your path\n -- note that rules files can include other rules files\n variables = default_variables,\n rules = [[ \n include $RULE_PATH\/snort3-community-rules\/snort3-community.rules\n include $RULE_PATH\/local.rules\n ]]\n}\n<\/code><\/pre>\n\n\n\n
Running Snort as a Service<\/h3>\n\n\n\n
-D<\/strong><\/code>, it is also possible to create a systemd service unit for Snort.<\/p>\n\n\n\n
useradd -r -s \/usr\/sbin\/nologin -M -c SNORT_IDS snort<\/code><\/pre>\n\n\n\n
vim \/etc\/systemd\/system\/snort3.service<\/code><\/pre>\n\n\n\n
[Unit]\nDescription=Snort 3 NIDS Daemon\nAfter=syslog.target network.target\n\n[Service]\nType=simple\nExecStart=\/usr\/local\/bin\/snort -c \/usr\/local\/etc\/snort\/snort.lua -s 65535 -k none -l \/var\/log\/snort -D -i enp0s8 -m 0x1b -u snort -g snort\nExecStop=\/bin\/kill -9 $MAINPID\n\n[Install]\nWantedBy=multi-user.target\n<\/code><\/pre>\n\n\n\n
systemctl daemon-reload<\/code><\/pre>\n\n\n\n
chmod -R 5775 \/var\/log\/snort<\/code><\/pre>\n\n\n\n
chown -R snort:snort \/var\/log\/snort<\/code><\/pre>\n\n\n\n
systemctl enable --now snort3<\/code><\/pre>\n\n\n\n
systemctl status snort3<\/code><\/pre>\n\n\n\n
\u25cf snort3.service - Snort 3 NIDS Daemon\n Loaded: loaded (\/etc\/systemd\/system\/snort3.service; enabled; vendor preset: enabled)\n Active: active (running) since Sat 2020-08-22 20:50:26 UTC; 1min 14s ago\n Main PID: 43673 (snort)\n Tasks: 2 (limit: 2282)\n Memory: 145.3M\n CGroup: \/system.slice\/snort3.service\n \u2514\u250043673 \/usr\/local\/bin\/snort -c \/usr\/local\/etc\/snort\/snort.lua -s 65535 -k none -l \/var\/log\/snort -D -i enp0s8 -m 0x1b -u snort -g snort\n\nAug 22 20:50:26 ubuntu20 systemd[1]: Started Snort 3 NIDS Daemon.\n<\/code><\/pre>\n\n\n\n
Reference<\/h3>\n\n\n\n
Further Reading<\/h3>\n\n\n\n
Related Tutorials<\/h3>\n\n\n\n