LogWatchで別に置いたiptablesのログを監視する。

Last-modified: Sun, 14 May 2017 18:38:50 JST (2540d)
Top > LogWatchで別に置いたiptablesのログを監視する。
  • iptablesのログファイルを別ファイルに分離していると、当然LogWatchは監視してくれませんので、設定します。
  • 動作環境はubuntu 16.04で確認しました。
  1. デフォルトの設定を変更する方法もあるのですが、アップデート時に面倒なことになりそうなので、
    別名でiptablesのデフォルト設定、スクリプトを持ってきます。
    cp /usr/share/logwatch/default.conf/services/iptables.conf /etc/logwatch/conf/services/iptables.conf
    
    cp /usr/share/logwatch/default.conf/logfiles/iptables.conf /etc/logwatch/conf/logfiles/iptables.conf
    
    cp /usr/share/logwatch/scripts/services/iptables  /etc/logwatch/scripts/services/iptables
  2. 参照するログファイルの場所を設定します。
    ここでは、/var/log/iptables.logにログが出力されているとします。
    vi /etc/logwatch/conf/logfiles/iptables.conf
    
    # What actual file?  Defaults to LogPath if not absolute path....
    #LogFile = ulogd/ulogd.syslogemu
    LogFile = /var/log/iptables.log
    
    
    # If the archives are searched, here is one or more line
    # (optionally containing wildcards) that tell where they are...
    #Archive = ulogd/ulogd.syslogemu.*
    #Archive = ulogd/ulogd.syslogemu-*
    Archive = /var/log/iptables.log.*.gz
  3. 参照するサービスの設定をします。
    vi /etc/logwatch/conf/services/iptables.conf
    
    Title = "iptables firewall"
    
    # Which logfile group...
    #LogFile = messages
    LogFile = iptables
  4. 動作確認をします。
logwatch --output stdout --service iptables  --range today

こんなのが出ればOKです。(もちろんパーズすべきログがないとダメですが・・)

 ################### Logwatch 7.4.2 (02/27/16) ####################
        Processing Initiated: Sun May 14 18:35:40 2017
        Date Range Processed: today
                              ( 2017-May-14 )
                              Period is day.
        Detail Level of Output: 0
        Type of Output/Format: stdout / text
        Logfiles for Host: dosmania.dip.jp
 ##################################################################

 --------------------- iptables firewall Begin ------------------------

 Listed by source hosts:
 Denied 76 packets on interface eth0
   From 5.255.253.8 - 3 packets to tcp(80)
   From 5.255.253.35 - 3 packets to tcp(80)
   From 37.9.113.33 - 3 packets to tcp(80)
   From 80.82.69.112 - 1 packet to tcp(80)

Counter: 673, today: 4, yesterday: 1

このページの参照回数は、673です。