###
# 包含配置
###
[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>