33
回編集
差分
→CentOS 8
==CentOS==
yum install -y epel-release
yum --enablerepo=epel -y install fail2ban
==securityログの設定==
/etc/asterisk/logger.confに
[logfiles]
security => security
==ステータス確認==
fail2ban-client コマンドで問い合わせるのがいいです。
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攻撃]]も防御できるようです。