0logwatch

 [root@falcon21 ~]# /etc/cron.daily/0logwatch

Cannot find shared script onlyservice


不正アクセスブロックプログラム fail2ban が干渉か?

ログを確認
[root@falcon21 ~]# tail -10 /var/log/fail2ban.log
2017-08-13 16:44:44,085 fail2ban.server [4275]: INFO Changed logging target to /var/log/fail2ban.log for Fail2ban v0.9.6
2017-08-13 16:44:44,099 fail2ban.database [4275]: INFO Connected to fail2ban persistent database '/var/lib/fail2ban/fail2ban.sqlite3'


自動起動設定確認
[root@falcon21 ~]# chkconfig --list fail2ban
fail2ban  0:off  1:off  2:off  3:on  4:on  5:on  6:off

[root@falcon21 ~]# chkconfig fail2ban on

[root@falcon21 ~]# chkconfig --list fail2ban
fail2ban  0:off  1:off  2:on  3:on  4:on  5:on  6:off

何故かランレベルが変わっていた。

起動確認
[root@falcon21 ~]# service fail2ban status
fail2ban-server (pid 4275) を実行中...
Status
|- Number of jail: 0
`- Jail list:


ログがデフォルトではsyslogに保存されるので/var/log/fail2ban/ 以下に保存するように変更

[root@falcon21 ~]# vi /etc/fail2ban/fail2ban.conf
35 #logtarget = SYSLOG
36 logtarget = /var/log/fail2ban/fail2ban.log


修正
[root@falcon21 ~]# vi /etc/fail2ban/jail.conf
20 # [DEFAULT]
21 # bantime = 3600
22 [DEFAULT]
23 bantime = 3600
24 #
25 # [sshd]
26 # enabled = true
27 [sshd]
28 enabled = true

113 #enabled = false
114 enabled = true


/var/log/fail2ban/fail2ban.log にログが残されると、ファイルサイズが肥大するので定期的にログをローテートする
[root@falcon21 ~]# vi /etc/logrotate.d/fail2ban
/var/log/fail2ban.log {
missingok
notifempty
   weekly
rotate 5
compress
dateext
creaye 0544 root root

postrotate
#      /usr/bin/fail2ban-client flushlogs >/dev/null || true
/usr/bin/fail2ban-client set logtarget /var/log/fail2ban/fail2ban.log 2> /dev/null || true
   endscript
}


[root@falcon21 ~]# service fail2ban restart
fail2ban デーモンを停止中: [ OK ]
fail2ban を起動中: ERROR Found no accessible config files for 'action.d/postfix-whois' under /etc/fail2ban
ERROR Error in action definition postfix-whois[name=asterisk, dest="root@falcon21.space"]
ERROR Errors in jail 'asterisk'. Skipping...
ERROR Error in action definition postfix-whois[name=freeswitch, dest="root@falcon21.space"]
ERROR Errors in jail 'freeswitch'. Skipping...
ERROR No file(s) found for glob /opt/openhab/logs/request.log
ERROR Failed during configuration: Have not found any log file for openhab-auth jail
[失敗]

ネットをググッタところ、fail2banインストールファイルで、足りないものがあるようで、不具合らしい。

取りあえず、fail2banは削除、logwatch を優先。


[root@falcon21 ~]# yum --enablerepo=epel remove fail2ban
トランザクションを実行しています
削除中 : fail2ban-0.9.6-1.el6.1.noarch 1/1
警告: /etc/logrotate.d/fail2ban は /etc/logrotate.d/fail2ban.rpmsave として保存されました。
警告: /etc/fail2ban/jail.conf は /etc/fail2ban/jail.conf.rpmsave として保存されました。
警告: /etc/fail2ban/fail2ban.conf は /etc/fail2ban/fail2ban.conf.rpmsave として保存されました。
Verifying : fail2ban-0.9.6-1.el6.1.noarch 1/1

削除しました:
fail2ban.noarch 0:0.9.6-1.el6.1

完了しました!

[root@falcon21 ~]# rm -f /etc/logrotate.d/fail2ban.rpmsave
[root@falcon21 ~]# rm -f /etc/fail2ban/jail.conf.rpmsave
[root@falcon21 ~]# rm -f /etc/fail2ban/fail2ban.conf.rpmsave


[root@falcon21 ~]# ll /var/log

-rw------- 1 root root 439 8月 14 09:53 2017 fail2ban.log
-rw------- 1 root root 1193 8月 4 10:31 2017 fail2ban.log-20170813

[root@falcon21 ~]# rm -f /var/log/fail2ban.log
[root@falcon21 ~]# rm -f /var/log/fail2ban.log-20170813
 


これで、logwatch を再インストールで、メールリポートが復帰

投票数:2 平均点:10.00

 
Back to Top