Fail2Ban とは

We need a means of defending sites against brute-force login attempts. Fail2Ban is a Python application which trails logfiles, looks for regular expressions and works with Shorewall (or directly with iptables) to apply temporary blacklists against addresses that match a pattern too often. This can be used to limit the rate at which a given machine hits login URLs for Confluence.

Prerequisites

セットアップ方法

このリストは説明の骨組みバージョンです

Fail2Ban の実行

共通設定

jail.local

# The DEFAULT を使用するとオプションをグローバルに定義できます。それ以降の各 jail の
 # を上書きする場合があります。

[DEFAULT]

# "ignoreip" は IP アドレス、CIDR マスクまたは DNS ホストのいずれかです。Fail2ban はこのリスト内のアドレスと一致するホストを
# ban しません。スペース区切りを使用して複数のアドレスを 
# で定義できます。
# ignoreip = <space-separated list of IPs>

# "bantime" はホストを禁止する秒数です。
bantime = 600

# 最後の "findtime"
# 秒の間に "maxretry" を生成した場合、ホストは禁止されます。
findtime = 60

# "maxretry" はホストが禁止されるまでの失敗の数です。
maxretry = 3


[ssh-iptables]

enabled = false


[apache-shorewall]

enabled = true
filter = cac-login
action = shorewall
logpath = /var/log/httpd/confluence-access.log
bantime = 600
maxretry = 3
findtime = 60
backend = polling

Confluence 向け設定

以下は設定例を示したもので、実際にはお客様のサイトに合わせて設定を行ってください。

filter.d/confluence-login.conf

[Definition]

failregex = <HOST>.*"GET /login.action

ignoreregex =