用途:
搭建集中日志管理系统,以用于后续朔源。默认情况下 rsyslog 服务是开启的,不过日志文件一般是保存在 var/log 本地目录下,对于有经验收的入侵者,入侵以后一般会清空 var/log 或者本机上所有的log文件,造成无法朔源的后果,集中日志服务器可解决该问题
一、服务端搭建(内网IP:192.168.225.83)
默认情况下 rsyslog 是安装好的,所以就如何安装 rsyslog 不再描述,百度上应该有很多
1、防火墙配置,增加如下命令
iptables -A INPUT -m state --state NEW -m udp -p udp -i eth0 --dport 514 -j ACCEPT
iptables -A INPUT -m state --state NEW -m tcp -p tcp -i eth0 --dport 514 -j ACCEPT
注意,一定要保存,重启iptables
service iptables save
service iptables restart
2、配置 rsyslog配置文件
配置文件路径:\etc\rsyslog.conf
配置如下,直接贴文件了,以下是我扩配置文件, 注意,为防止log把系统盘撑爆,以及超级大文件的产品,本服务器在配置的时候将保存目录移动 /mnt/log 下,文件保存方式为一天一个文件,格式为 security_20180321 ...., 方便查询
# rsyslog v5 configuration file
# For more information see /usr/share/doc/rsyslog-*/rsyslog_conf.html
# If you experience problems, see http://www.rsyslog.com/doc/troubleshoot.html
#### MODULES ####
$ModLoad imuxsock # provides support for local system logging (e.g. via logger command)
$ModLoad imklog # provides kernel logging support (previously done by rklogd)
$ModLoad immark # provides --MARK-- message capability
# Provides UDP syslog reception
#$ModLoad imudp
#$UDPServerRun 514
# Provides TCP syslog reception
$ModLoad imtcp
$InputTCPServerRun 514
#### GLOBAL DIRECTIVES ####
# Use default timestamp format
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
# File syncing capability is disabled by default. This feature is usually not required,
# not useful and an extreme performance hit
#$ActionFileEnableSync on
# Include all config files in /etc/rsyslog.d/
$IncludeConfig /etc/rsyslog.d/*.conf