Rsyslog : Output Logs to Remote Host2015/06/18 |
Configure Rsyslog to output logs to remote host.
This example based on environment below. +----------------------+ | +----------------------+ | [ Syslog Server ] |10.0.0.30 | 10.0.0.51| [ Syslog Client ] | | dlp.srv.world +----------+----------+ node01.srv.world | | | | | +----------------------+ +----------------------+ |
[1] | Configure Log Managed Server to receive logs from client servers. |
[root@dlp ~]#
vi /etc/rsyslog.conf # line 19-20: uncomment $ModLoad imtcp $InputTCPServerRun 514 # specify senders you permit to access
$AllowedSender TCP, 127.0.0.1, 10.0.0.0/24, *.srv.world
systemctl restart rsyslog |
[2] | Configure Client Servers. |
[root@node01 ~]#
vi /etc/rsyslog.conf # for example, output logs for "authpriv.*" to remote host authpriv.* @@dlp.srv.world:514
# line 73: uncomment all $ActionQueueFileName fwdRule1 # unique name prefix for spool files $ActionQueueMaxDiskSpace 1g # 1gb space limit (use as much as possible) $ActionQueueSaveOnShutdown on # save messages to disk on shutdown $ActionQueueType LinkedList # run asynchronously $ActionResumeRetryCount -1 # infinite retries if host is down[root@node01 ~]# systemctl restart rsyslog |
[3] | After configuration of above, logs for kinds of authentication are recorded on Log Managed Server like follows. |
[root@dlp ~]# tail -10 /var/log/secure Jun 17 11:24:47 dlp sshd[9582]: Connection closed by 127.0.0.1 [preauth] Jun 17 11:27:46 node01 login: pam_unix(login:session): session closed for user root Jun 17 11:27:52 node01 login: pam_unix(login:auth): check pass; user unknown Jun 17 11:27:52 node01 login: pam_unix(login:auth): authentication failure; logname=LOGIN uid=0 euid=0 Jun 17 11:27:54 node01 login: FAILED LOGIN 1 FROM ttyS0 FOR (unknown), User not known to the underlyin Jun 17 11:27:59 node01 login: pam_unix(login:session): session opened for user root by LOGIN(uid=0) Jun 17 11:27:59 node01 login: DIALUP AT ttyS0 BY root Jun 17 11:27:59 node01 login: ROOT LOGIN ON ttyS0 Jun 17 11:28:44 node01 su: pam_unix(su-l:session): session opened for user cent by root(uid=0) Jun 17 11:28:54 node01 sudo: cent : TTY=ttyS0 ; PWD=/home/cent ; USER=root ; COMMAND=/bin/cat /etc/sha |
[4] | If you'd like to separate logs for each Host, for each date, Configure like follows. |
[root@dlp ~]#
vi /etc/rsyslog.conf # add: define logfiles
$template Secure_log,"/var/log/secure.d/%fromhost%_%$year%%$month%%$day%.secure"
# add: specify logfiles defined above authpriv.* -?Secure_log
[root@dlp ~]#
[root@dlp ~]# systemctl restart rsyslog
ll /var/log/secure.d total 8 -rw-r--r-- 1 root root 350 Jun 17 11:34 dlp_20150617.secure -rw-r--r-- 1 root root 380 Jun 17 11:34 node01.srv.world_20150617.secure |
Sponsored Link |
|