Fail2ban 配置詳解 動作配置


###
# 包含配置
###
[INCLUDES]
before = iptables-common.conf

###
# 定義動作
###
[Definition]
actionstart = <iptables> -N f2b-<name>
              <iptables> -A f2b-<name> -j <returntype>
              <iptables> -I <chain> -p <protocol> --dport <port> -j f2b-<name>
# 定義在啟動監禁(jail)時會執行一次的動作。

actionstop = <iptables> -D <chain> -p <protocol> --dport <port> -j f2b-<name>
             <iptables> -F f2b-<name>
             <iptables> -X f2b-<name>
# 定義在停止監禁(jail)時會執行的動作。

actioncheck = <iptables> -n -L <chain> | grep -q 'f2b-<name>[ \t]'
# 定義在禁止IP"actionban"前執行檢查的動作,用於檢測IPtables命令是否能夠成功執行。

actionban = <iptables> -I f2b-<name> 1 -s <ip> -j <blocktype>
# 定義禁止IP時要執行的動作,該命令是使用fail2ban用戶權限執行的。

actionunban = <iptables> -D f2b-<name> -s <ip> -j <blocktype>
# 定義在解除禁止時要執行的動作,該命令是使用fail2ban用戶權限執行的。

###
# 初始化動作
# 定義當未在監禁中關聯動作時,允許設置的"<參數>",可以鍵入一些默認值,若在監禁中未傳遞參數,則fail2ban
# 會自動引用默認值。
###
[Init]
chain = INPUT
name = default
port = ssh
protocol = tcp
blocktype = REJECT --reject-with icmp-port-unreachable
returntype = RETURN
lockingopt = -w
iptables = iptables <lockingopt>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM