yum install –y gcc flex bison zlib* libpcap* tcpdump gcc-c++ zlib* libdnet libdnet-devel pcre*
wget https://phoenixnap.dl.sourceforge.net/project/libdnet/libdnet/libdnet-1.11/libdnet-1.11.tar.gz
tar -zxvf libdnet-1.11.tar.gz
cd libdnet-1.11
./configure
make
make install
wget http://www.tcpdump.org/release/libpcap-1.8.1.tar.gz
tar -zxvf libpcap-1.8.1.tar.gz
cd libpcap-1.8.1
./configure
make
make install
wget https://www.snort.org/downloads/snort/daq-2.0.6.tar.gz
tar -zxvf daq-2.0.6.tar.gz
cd daq-2.0.6
./configure
make
make install
wget https://www.snort.org/downloads/archive/snort/snort-2.9.11.1.tar.gz
tar -zxvf snort-2.9.11.1.tar.gz
cd snort-2.9.11.1
./configure --prefix=/usr/local/snort --enable-pthread --enable-gre --enable-mpls --enable-targetbased
make
make install
验证
输入:#snort -V
出现一头小猪,并显示正确的版本号,说明snort已经安装成功。
运行#snort –V出现:
错误:找不到命令。原因是系统找不到snort的路径。
解决:
执行命令:
export PATH=$PATH:/usr/local/snort/bin
原因:
snort安装完毕,没有在系统路径变量PATH中,添加snort可执行文件路径。
mkdir /etc/snort
mkdir /var/log/snort #存放日志文件
mkdir /usr/local/lib/snort_dynamicrules
mkdir /etc/snort/rules #存放规则
cp /etc/snort/snort-2.9.11.1/etc/* /etc/snort/rules
#编辑配置文件
vi /etc/snort/snort.conf
#修改路径
var HOME_NET 10.60.250.0/24
var RULE_PATH /etc/snort/rules
var EXTERNAL_NET !$HOME_NET
#设置log目录
config logdir:/var/log/snort
#配置输出插件
Snort输出设置在snort.conf文件的
Step #6: Configure output plugins
output unified2: filename merged.log, limit 128, nostamp, mpls_event_types, vlan_event_types
yum install -y mysql mysql-server mysql-devel
mysql --version #查看mysql版本
service mysqld start #启动mysql
要启动MySQL数据库是却是这样的提示
Failed to start mysqld.service: Unit not found
解决方法如下:
首先需要安装mariadb-server
~]# yum install -y mariadb-server
启动服务
~]# systemctl start mariadb.service
添加到开机启动
~]# systemctl enable mariadb.service
mysql -u root -p #使用root登录,默认不用密码
use mysql
update user set password=password('root') where user='root'; #设置用户root的登录密码
create database snort;
grant create,select,update,insert,delete on snort.* to snort@localhost identified by '123456'; #创建名为snort、密码为123456的数据库用户并赋予名为snort数据库权限
exit #退出
wget https://codeload.github.com/firnsy/barnyard2/zip/master 下载barnyard2
mv master /etc/snort/barnyard2.zip
cd /etc/snort
unzip barnyard2.zip
cd barnyard2-master
mysql -u snort -p -Dsnort < /etc/snort/barnyard2-master/schemas/create_mysql #根据特定的格式创建数据库表
#进入mysql验证表是否创建成功
mysql -u root -p
123456 #密码
use snort;
show tables; #查看snort数据库中表是否创建成功,
成功如图
vi /etc/snort/snort.conf
7) Customize your rule set
部分下面进行配置。
在其下添加include $RULE_PATH/etc/snort/rules
把其余的注释掉
配置文件中要把所有的没有 \的未注释的都加上 \ (注意是空格和斜杠)
snort -T -i eth1 -c /etc/snort/snort.conf
参数解释:
-T 指定启动模式:测试
-i 指定网络接口
-c 指定配置文件
成功
#之前解压过barnyard2,所以直接cd到解压后的目录
cd /etc/snort/barnyard2-master
sudo yum -y install libtool //安装libtool,否则出现no libtoolize错误。
./autogen.sh
./configure --with-mysql --with-mysql-libraries=/usr/lib64/mysql/
make
make install
sudo groupadd snort
useradd snort –g snort //创建snort组、snort用户
sudo mkdir /var/log/snort /var/log/barnyard2
touch /var/log/snort/barnyard2.waldo
chown snort.snort /var/log/snort/barnyard2.waldo
sudo chown -R snort.snort /var/log/snort
sudo chown -R snort.snort /var/log/barnyard2 //创建日志目录,并授权
#修改配置文件
cp /usr/local/etc/barnyard2.conf /etc/snort
vi /etc/snort/barnyard2.conf
1、找到 output alert_fast: stdout 改为:
output alert_fast
2、访问数据库设置
在database设置部分,找到mysql相关的,去掉注释符号#,并修改为:
output database: log, mysql, user=snort password= 123456 dbname=snort host=localhost
barnyard2 -c /etc/snort/barnyard2.conf -d /var/log/snort -f snort.log -w /var/log/snort/barnyard2.waldo
参数解释:
-c 指定配置文件
-d 指定log目录
-f 指定log文件
-w 指定waldo文件
出错1:barnyard2 error while loading shared libraries libmysqlclient.so.21
解决:
sudo find –name libmysqlclient.so.21 //找到了,在/usr/local/mysql/lib目录下
ln -s /usr/local/mysql/lib/libmysqlclient.so.21 /usr/lib/libmysqlclient.so.21 //32位系统
ln -s /usr/local/mysql/lib/libmysqlclient.so.21 /usr/lib64/libmysqlclient.so.21 //64位系统
出错2:Unable to open SID file ‘/etc/snort/sid-msg.map’
解决:
将规则文件community-rules.tar解压到/etc/snort/目录下。
wget https://www.snort.org/downloads/community/community-rules.tar.gz
tar -zxvf community-rules.tar.gz
mv community-rules /etc/snort
出错3:database mysql_error: Access denied for user ‘root’@‘localhost’ (using password: YES)
解决:
vim /etc/snort/barnyard2.conf
出现下图,说明配置成功
至此snort和barnyard2的安装配置已完成
下面的就可以进行 Apache+php安装了。这里就不再演示了。自行安装完成,然后就可以进行测试了。
手机扫一扫
移动阅读更方便
你可能感兴趣的文章