http://www.tuicool.com/articles/v6j2Ab

Snort is by far the most popular open-source network intrusion detection and prevention system (IDS/IPS) for Linux. Snort can conduct detailed traffic analysis, including protocol analysis, packet content searching and matching, all in real-time. The latest Snort rule sets are available for download either for free or with a paid subscription.

You can install Snort from its source code or binary rpm/deb packages on Linux. There are several reasons why you want to build Snort from source code, not install it from Linux packages. For example, you want to use the latest version of Snort, which may not be available in Linux distro repositories. Also, you may want to customize Snort binary in any way (e.g., plug in a custom DAQ module, use a particular version of libpcap library, etc.).

In this tutorial, I will describe how to compile and install Snort from source code .
Compile and Install Snort and Its Dependencies

First, install prerequisites for compiling Snort.
$ sudo apt-get install flex bison build-essential checkinstall libpcap-dev libnet1-dev libpcre3-dev libmysqlclient15-dev libnetfilter-queue-dev iptables-dev

Next, build and install libdnet from its source code. The “-fPIC” C flag is necessary if you compile it on 64-bit platform.
$ wget https://libdnet.googlecode.com/files/libdnet-1.12.tgz
$ tar xvfvz libdnet-1.12.tgz
$ ./configure “CFLAGS=-fPIC”
$ make
$ sudo checkinstall

The checkinstall command above will build .deb package. and while doing so, ask you several questions. You can accept default values.

Install .deb package, and create a symbolic link where Snort looks for libdnet .
$ sudo dpkg -i libdnet_1.12-1_amd64.deb
$ sudo ln -s /usr/local/lib/libdnet.1.0.1 /usr/lib/libdnet.1

Next, build and install DAQ (Data Acquisition) library. DAQ is an abstraction layer for packet I/O, which allows you to plug different DAQ modules into Snort, to support different hardware/software interfaces for packet I/O, without changing Snort itself. DAQ source code is available from here .
$ tar xvfvz daq-2.0.0.tar.gz
$ cd daq-2.0.0
$ ./configure
$ make
$ sudo checkinstall
$ sudo dpkg -i daq_2.0.0-1_amd64.deb

Next, compile and install Snort itself. Snort source code is available here .
$ tar xvfvz snort-2.9.5.tar.gz
$ cd snort-2.9.5
$ ./configure
$ make
$ sudo checkinstall
$ sudo dpkg -i snort_2.9.5-1_amd64.deb
$ sudo ln -s /usr/local/bin/snort /usr/sbin/snort

Finally, run ldconfig command, so that dynamic linker run-time bindings for libdnet and DAQ libraries are properly set up.
$ sudo ldconfig -v

After this, verify that Snort is installed successfully.
$ snort -V

,,_     -*> Snort! <*-
  o"  )~   Version 2.9.5 GRE (Build 103)
   ''''    By Martin Roesch & The Snort Team:
http://www.snort.org/snort/snort-team
           Copyright (C) 1998-2013 Sourcefire, Inc., et al.
           Using libpcap version 1.3.0
           Using PCRE version: 8.31 2012-07-06
           Using ZLIB version: 1.2.7

Configure Snort and Download Snort Rule Sets

After installation, go ahead and configure Snort as follows.

For security reason, it is recommended to create a separate Linux user which Snort will run as.
$ sudo groupadd snort
$ sudo useradd snort -d /var/log/snort -s /sbin/nologin -c SNORT_IDS -g snort

Create a log directory for Snort.
$ sudo mkdir /var/log/snort
$ sudo chown snort:snort /var/log/snort

Download Snort rule sets . You can download a registered user release for free. After download, install and configure Snort rules as follows.
$ sudo mkdir /etc/snort
$ sudo tar xvfvz snortrules-snapshot-2950.tar.gz -C /etc/snort
$ sudo touch /etc/snort/rules/white_list.rules /etc/snort/rules/black_list.rules
$ sudo mkdir /usr/local/lib/snort_dynamicrules
$ sudo chown -R snort:snort /etc/snort/*
$ sudo mv /etc/snort/etc/* /etc/snort

Edit a default Snort configuration to point to correct ruleset directories. Also define HOME_NET which is the network to protect with Snort.
$ sudo vi /etc/snort/snort.conf

var RULE_PATH /etc/snort/rules
var SO_RULE_PATH /etc/snort/so_rules
var PREPROC_RULE_PATH /etc/snort/preproc_rules
var WHITE_LIST_PATH /etc/snort/rules
var BLACK_LIST_PATH /etc/snort/rules
ipvar HOME_NET 192.168.1.0/24
ipvar EXTERNAL_NET !$HOME_NET

Run Snort in Self-Test Mode

After configuration is done, you can test Snort by using the following command. This command will launch Snort in self-test mode, and check if rules are successfully loaded. I assume that eth0 is the network interface that Snort is listening on.
$ sudo snort -T -i eth0 -u snort -g snort -c /etc/snort/snort.conf

If Snort passes all the tests successfully, you should see the following messages:

Snort successfully validated the configuration!
Snort exiting

How to compile and install Snort from source code on Ubuntu的更多相关文章

  1. Increasing heap size while building the android source code on Ubuntu 15.10

    http://stackoverflow.com/questions/34940793/increasing-heap-size-while-building-the-android-source-c ...

  2. How to compile and install Linux Kernel 5.1.2 from source code

    How to compile and install Linux Kernel 5.1.2 from source code Compiling a custom kernel has its adv ...

  3. How to Build MySQL from Source Code on Windows & compile MySQL on win7+vs2010

    Not counting obtaining the source code, and once you have the prerequisites satisfied, [Windows] use ...

  4. Ubuntu 16.04上源码编译Poco并编写cmake文件 | guide to compile and install poco cpp library on ubuntu 16.04

    本文首发于个人博客https://kezunlin.me/post/281dd8cd/,欢迎阅读! guide to compile and install poco cpp library on u ...

  5. Windows 10上源码编译Poco并编写httpserver和tcpserver | compile and install poco cpp library on windows

    本文首发于个人博客https://kezunlin.me/post/9587bb47/,欢迎阅读! compile and install poco cpp library on windows Se ...

  6. Maven学习笔记1(clean compile package install)

    Maven是一个项目构建管理工具,使用相应的命令 就可以快速完成项目的编译 打包. 1.下载maven,直接解压目录就可以了,配置maven的环境变量就可以在window下的任何文件夹下以命令的方式执 ...

  7. mvn clean compile package install deploy

    (1) package 目的是打包,在pom中,如果是jar就会打包成jar,如果是war就会打包成war 在pom.xml中: <modelVersion></modelVersi ...

  8. ubuntu 16.04上源码编译和安装cgal并编写CMakeLists.txt | compile and install cgal on ubuntu 16.04

    本文首发于个人博客https://kezunlin.me/post/39ab7ed9/,欢迎阅读最新内容! compile and install cgal on ubuntu 16.04 Guide ...

  9. ubuntu 16.04 上编译和安装C++机器学习工具包mlpack并编写mlpack-config.cmake | tutorial to compile and install mplack on ubuntu 16.04

    本文首发于个人博客https://kezunlin.me/post/1cd6a04d/,欢迎阅读最新内容! tutorial to compile and install mplack on ubun ...

随机推荐

  1. Adobe Photoshop CS6简单的破解

    由于网站的页面布局和素材准备等等需要用到Photoshop,所以下载了个 Photoshop CS6,写这份破解文档的大佬感觉写的很复杂,看了让人头疼,乱搞中突然发现一个方法可以很快的进行破解操作,我 ...

  2. day7 七、字符编码,字符字节与文件操作

    一.字符编码 1.定义:人类能识别的是字符等高级标识符,电脑只能识别0,1组成的标识符,要完成人与机器之间的信息交流,一定需要一个媒介,进行两种标识符的转化(两种标识符的对应关系) 对应关系形成的结构 ...

  3. PAT甲级1061 Dating

    题目:https://pintia.cn/problem-sets/994805342720868352/problems/994805411985604608 题意: 给定四个字符串. 前两个字符串 ...

  4. 【TOP100案例专访】当当网工程师林嘉琦谈双11大促经验及APM实践

    导读:第七届TOP100全球软件案例研究峰会将于11月30日-12月3日在北京国家会议中心举办,本届峰会以“释放AI生产力 让组织向智能化演进”为开幕式主题,旨在推动企业在趋势下拥抱AI.探索和思考A ...

  5. linux下升级gcc版本(gcc-7)

    ubuntu16.04的自带gcc版本为gcc-5,因为安装pl-slam的需要升级到gcc-7,可以通过以下命令查看你的gcc版本 gcc --version 通过apt工具对gcc进行升级 sud ...

  6. HDU 2072 - 单词数 - [(有点小坑的)字典树模板题]

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2072 Problem Descriptionlily的好朋友xiaoou333最近很空,他想了一件没有 ...

  7. tensorflow模型在实际上线进行预测的时候,使用CPU工作

    最近已经训练好了一版基于DeepLearning的文本分类模型,TextCNN原理.在实际的预测中,如果默认模型会优先选择GPU那么每一次实例调用,都会加载GPU信息,这会造成很大的性能降低. 那么, ...

  8. iOS 精简Controlelr代码的两个方法

    MVC是苹果推荐使用的iOS APP架构.后来又有MVVM,MVP等架构出现.主要目的是让业务逻辑.展示.数据各个层级解耦.实现最大程度上的代码复用. 对MVC这种架构来说,随着APP中模的增多,控制 ...

  9. AndroidStudio_ListView

    在这里梳理一下ListView的用法: 1.建立一个activity,例如建立一个ListViewActivity,这时将生成两个文件:ListViewActivity.java和activity_l ...

  10. python导入方法,软件目录

    软件目录 import os #print(__file__)#打印当前文件相对路径(文件,发要) import sys BASE_DIR=os.path.dirname(os.path.dirnam ...