「SIP-Fail2ban」の版間の差分
ナビゲーションに移動
検索に移動
新しいページ: '==fail2ban== ログファイルとiptablesを利用したファイアウォールの一種。Brute Forceアタックの対策に使いやすい。<br> :http://www.fail2ban.org/...' |
編集の要約なし |
||
4行目: | 4行目: | ||
:http://sourceforge.net/projects/fail2ban/ | :http://sourceforge.net/projects/fail2ban/ | ||
==動作条件== | ==動作条件== | ||
pythonとiptablesが必要。yum install python | pythonとiptablesが必要。yum install python iptablesなどで入れておいて下さい。 | ||
==インストール== | ==インストール== | ||
まずSFからfail2banをダウンロードし、展開します。 | |||
tar jxvf fail2ban-0.8.4.tar.bz2 | tar jxvf fail2ban-0.8.4.tar.bz2 | ||
展開したディレクトリでインストールを実行します。 | |||
cd fail2ban-0.8.4 | cd fail2ban-0.8.4 | ||
python ./setup.py | python ./setup.py | ||
スタートアップ・スクリプトをコピーしておきます(CentOSなどRedHat系の場合の例)。 | |||
cp files/redhat-initd /etc/init.d/fail2ban | cp files/redhat-initd /etc/init.d/fail2ban | ||
==設定== | ==設定== | ||
===Asteriskのログフォーマットを変更する=== | |||
Fail2banはそのままではAsteriskのログの日付を認識できないため、Asteriskのログフォーマットを変更します。<br> | |||
/etc/asterisk/logger.confを編集し、日付のフォーマット変更を行います。<br> | |||
[general]セクションにある | |||
dateformat=%F %T | |||
のコメントを外すか、もしこのエントリがなければ記述します。設定を変更したら、Asteriskを再起動するか、loggerモジュールのリロードを行って、変更を有効にします。これによりAsteriskのログの日付形式が以下のように変わりますので、確認してください。 | |||
[2010-12-30 09:25:25] NOTICE[17537] chan_sip.c:..... | |||
===Asterisk用の定義ファイルを作る=== | |||
/etc/fail2ban/filter.d ディレクトリに asterisk.conf という名前で以下のようなファイルを作ります。<br> | |||
<br> | |||
Asterisk 1.8系の場合 | |||
# Fail2Ban configuration file | |||
# | |||
# | |||
# $Revision: 250 $ | |||
# | |||
[INCLUDES] | |||
# Read common prefixes. If any customizations available -- read them from | |||
# common.local | |||
#before = common.conf | |||
[Definition] | |||
#_daemon = asterisk | |||
# Option: failregex | |||
# Notes.: regex to match the password failures messages in the logfile. The | |||
# host must be matched by a group named "host". The tag "<HOST>" can | |||
# be used for standard IP/hostname matching and is only an alias for | |||
# (?:::f{4,6}:)?(?P<host>\S+) | |||
# Values: TEXT | |||
# | |||
failregex = Registration from '.*' failed for '<HOST>(:[0-9]{1,5})?' - Wrong password | |||
Registration from '.*' failed for '<HOST>(:[0-9]{1,5})?' - No matching peer found | |||
Registration from '.*' failed for '<HOST>(:[0-9]{1,5})?' - Username/auth name mismatch | |||
Registration from '.*' failed for '<HOST>(:[0-9]{1,5})?' - Device does not match ACL | |||
Registration from '.*' failed for '<HOST>(:[0-9]{1,5})?' - Peer is not supposed to register | |||
Registration from '.*' failed for '<HOST>(:[0-9]{1,5})?' - Not a local domain | |||
# Option: ignoreregex | |||
# Notes.: regex to ignore. If this regex matches, the line is ignored. | |||
# Values: TEXT | |||
# | |||
ignoreregex = |
2010年12月30日 (木) 09:36時点における版
fail2ban
ログファイルとiptablesを利用したファイアウォールの一種。Brute Forceアタックの対策に使いやすい。
動作条件
pythonとiptablesが必要。yum install python iptablesなどで入れておいて下さい。
インストール
まずSFからfail2banをダウンロードし、展開します。
tar jxvf fail2ban-0.8.4.tar.bz2
展開したディレクトリでインストールを実行します。
cd fail2ban-0.8.4 python ./setup.py
スタートアップ・スクリプトをコピーしておきます(CentOSなどRedHat系の場合の例)。
cp files/redhat-initd /etc/init.d/fail2ban
設定
Asteriskのログフォーマットを変更する
Fail2banはそのままではAsteriskのログの日付を認識できないため、Asteriskのログフォーマットを変更します。
/etc/asterisk/logger.confを編集し、日付のフォーマット変更を行います。
[general]セクションにある
dateformat=%F %T
のコメントを外すか、もしこのエントリがなければ記述します。設定を変更したら、Asteriskを再起動するか、loggerモジュールのリロードを行って、変更を有効にします。これによりAsteriskのログの日付形式が以下のように変わりますので、確認してください。
[2010-12-30 09:25:25] NOTICE[17537] chan_sip.c:.....
Asterisk用の定義ファイルを作る
/etc/fail2ban/filter.d ディレクトリに asterisk.conf という名前で以下のようなファイルを作ります。
Asterisk 1.8系の場合
# Fail2Ban configuration file # # # $Revision: 250 $ # [INCLUDES] # Read common prefixes. If any customizations available -- read them from # common.local #before = common.conf [Definition] #_daemon = asterisk # Option: failregex # Notes.: regex to match the password failures messages in the logfile. The # host must be matched by a group named "host". The tag "<HOST>" can # be used for standard IP/hostname matching and is only an alias for # (?:::f{4,6}:)?(?P<host>\S+) # Values: TEXT # failregex = Registration from '.*' failed for '<HOST>(:[0-9]{1,5})?' - Wrong password Registration from '.*' failed for '<HOST>(:[0-9]{1,5})?' - No matching peer found Registration from '.*' failed for '<HOST>(:[0-9]{1,5})?' - Username/auth name mismatch Registration from '.*' failed for '<HOST>(:[0-9]{1,5})?' - Device does not match ACL Registration from '.*' failed for '<HOST>(:[0-9]{1,5})?' - Peer is not supposed to register Registration from '.*' failed for '<HOST>(:[0-9]{1,5})?' - Not a local domain # Option: ignoreregex # Notes.: regex to ignore. If this regex matches, the line is ignored. # Values: TEXT # ignoreregex =