104 var RULE_PATH /etc/snort/rules --这几句必须全部改成绝对路径,如果用默认的相对路径,其它
参数在调用时,相对的目录就不一样了(这一句默认就是绝对路径,但下面几句是相对路径,需要修改)
105 var SO_RULE_PATH /etc/snort/so_rules
106 var PREPROC_RULE_PATH /etc/snort/preproc_rules
113 var WHITE_LIST_PATH /etc/snort/rules
114 var BLACK_LIST_PATH /etc/snort/rules
4,确认服务启动配置文件里的网卡名称(如果你的网卡名是eth0,那可以直接跳过这步;但如果不是eth0,则需要修改
下面两个文件的两个地方)
# vim /etc/rc.d/init.d/snortd
47 INTERFACE="-i eth0" --不是eth0的对应的改成你的网卡名称
# vim /etc/sysconfig/snort
15 INTERFACE=eth0 --不是eth0的对应的改成你的网卡名称
5,启动服务前,使用下面命令进行自我检测
# snort -T -i eth0 -u snort -g snort -c /etc/snort/snort.conf
报错:
ERROR: /etc/snort/snort.conf(253) Could not stat dynamic module path
"/usr/local/lib/snort_dynamicrules": No such file or directory.
解决方法:
# mkdir -p /usr/local/lib/snort_dynamicrules
# chown -R snort:snort /usr/local/lib/snort_dynamicrules
# chmod -R 700 /usr/local/lib/snort_dynamicrules
# snort -T -i eth0 -u snort -g snort -c /etc/snort/snort.conf --再让snort做自我检测,最
后报如下两句,则表示成功
......
......
......
Snort successfully validated the configuration!
Snort exiting
6,启动snort服务
# systemctl start snortd
# ps -ef |grep snort |grep -v grep --验证有下面的进程,表示启动ok
snort 7482 1 0 16:14 ? 00:00:00 /usr/sbin/snort -A fast -b -d -D -i
eth0 -u snort -g snort -c /etc/snort/snort.conf -l /var/log/snort
7,测试
# vim /etc/snort/rules/local.rules --这是/etc/snort/snort.conf里读取的N条规则中的其中一条,
是个空文件,以它做测试,写上下面一条规则(表示任何icmp包都会警告)
alert icmp any any -> any any (msg:"ICMP Testing Rule"; sid:1000001;)
# systemctl restart snortd