差分

移動先: 案内検索

SIP-Fail2ban

1,858 バイト追加, 2020年8月7日 (金) 19:40
CentOS 8
==CentOS==
CentOSではeaplからyumでインストールすることが可能です。CentOSではepelからyumでインストールすることが可能です。
yum install -y epel-release
yum --enablerepo=epel -y install fail2ban
==ステータス確認==
fail2ban-client コマンドで問い合わせるのがいいです。
fail2ban-client # コマンド一覧 fail2ban-client status # 有効なjail一覧 fail2ban-client status asterisk # jail名"asterisk"のステータス fail2ban-client status asterisk # 手動でban/unban fail2ban-client set asterisk banip 11.22.33.44 fail2ban-client set asterisk unbanip 11.22.33.44
banされてることになっていても、actionが正しく書けていないと実際にはfirewalldやiptablesなどに反映されず、攻撃されっぱなしもあり得るので、挙動確認が大事です。<br>
fail2ban-server コマンドは直接叩いてはいけないようです。<br>
または、ログファイル /var/log/fail2ban.log を見てもいいです。
== CentOS 8 ==
 
Asterisk16, CentOS 8でも同様にepelからdnfでインストールすることが可能です。<BR>
CentOS 8では、iptablesではなく、nftables及びfirewalldが使用されていますが、問題なく対応しています。
dnf install -y epel-release
dnf --enablerepo=epel -y install fail2ban fail2ban-systemd
 
Asteriskのlogger.confの変更、/etc/fail2ban/jail.localの作成は上記、[[#CentOS|以前のCentOS]]と同様にしてください。<BR>
しかし、2020年8月7日時点では、ここでfail2banを起動しても
2020-08-07 16:39:54,981 fail2ban.transmitter [58697]: WARNING Command ['server-stream', [['set', 'syslogsocket', 'auto']
(略)
Received ValueError('Action firewallcmd-rich-rules already exists',)
2020-08-07 16:39:54,981 fail2ban [58697]: ERROR NOK: ('Action firewallcmd-rich-rules already exists',)
 
というエラーが出て動きません。さしあたりの回避策として/etc/fail2ban/jail.d/00-firewalld.confを次のように変更します。
(略)
[DEFAULT]
banaction = firewallcmd-ipset
banaction_allports = firewallcmd-ipset
#banaction = firewallcmd-rich-rules[actiontype=<multiport>]
#banaction_allports = firewallcmd-rich-rules[actiontype=<allports>]
 
これでfail2banを起動すると監視が始まります。
systemctl enable fail2ban
systemctl start fail2ban
 
稼働状態の確認としては、上記fail2ban-clientコマンドまたは、次のコマンドが使用できます。
ipset --list
Asterisk 16及び[[Category:セキュリティAsterisk pjsip|pjsip]]を使用していると、Asteriskにパッチを当てる等しなくても[[#INVITEによるBrute force攻撃への対策|INVITEによるBrute force攻撃]]も防御できるようです。

案内メニュー

VoIp-Info.jp

HP Directplus -HP公式オンラインストア-