# Fail2Ban action file for firewall-cmd/ipset # # This requires: # ipset (package: ipset) # firewall-cmd (package: firewalld) # # This is for ipset protocol 6 (and hopefully later) (ipset v6.14). # Use ipset -V to see the protocol and version. # # IPset was a feature introduced in the linux kernel 2.6.39 and 3.0.0 kernels. # # If you are running on an older kernel you make need to patch in external # modules. [INCLUDES] before = firewallcmd-common.conf [Definition] actionstart = /actionstart> firewall-cmd --direct --add-rule filter 0 -m set --match-set src -j actionflush = /actionflush> actionstop = firewall-cmd --direct --remove-rule filter 0 -m set --match-set src -j /actionstop> actionban = /actionban> # actionprolong = %(actionban)s actionunban = /actionunban> [ipstype_ipset] actionstart = ipset -exist create hash:ip timeout maxelem actionflush = ipset flush actionstop = ipset destroy actionban = ipset -exist add timeout actionunban = ipset -exist del [ipstype_firewalld] actionstart = firewall-cmd --direct --new-ipset= --type=hash:ip --option=timeout= --option=maxelem= # TODO: there doesn't seem to be an explicit way to invoke the ipset flush function using firewall-cmd actionflush = actionstop = firewall-cmd --direct --delete-ipset= actionban = firewall-cmd --ipset= --add-entry= actionunban = firewall-cmd --ipset= --remove-entry= [Init] # Option: chain # Notes specifies the iptables chain to which the fail2ban rules should be # added # Values: [ STRING ] # chain = INPUT_direct # Option: default-ipsettime # Notes: specifies default timeout in seconds (handled default ipset timeout only) # Values: [ NUM ] Default: 0 (no timeout, managed by fail2ban by unban) default-ipsettime = 0 # Option: ipsettime # Notes: specifies ticket timeout (handled ipset timeout only) # Values: [ NUM ] Default: 0 (managed by fail2ban by unban) ipsettime = 0 # Option: maxelem # Notes: maximal number of elements which can be stored in the ipset # You may want to increase this for long-duration/high-volume jails # Values: [ NUM ] Default: 65536 maxelem = 65536 # expression to calculate timeout from bantime, example: # banaction = %(known/banaction)s[ipsettime=''] timeout-bantime = $([ "" -le 2147483 ] && echo "" || echo 0) # Option: ipsettype # Notes.: defines type of ipset used for match-set (firewalld or ipset) # Values: firewalld or ipset # Default: ipset ipsettype = ipset # Option: actiontype # Notes.: defines additions to the blocking rule # Values: leave empty to block all attempts from the host # Default: Value of the multiport actiontype = # Option: allports # Notes.: default addition to block all ports # Usage.: use in jail config: banaction = firewallcmd-ipset[actiontype=] # for all protocols: banaction = firewallcmd-ipset[actiontype=""] allports = -p # Option: multiport # Notes.: addition to block access only to specific ports # Usage.: use in jail config: banaction = firewallcmd-ipset[actiontype=] multiport = -p -m multiport --dports ipmset = f2b- familyopt = firewalld_familyopt = [Init?family=inet6] ipmset = f2b-6 familyopt = family inet6 firewalld_familyopt = --option=family=inet6 # DEV NOTES: # # Author: Edgar Hoch, Daniel Black, Sergey Brester and Mihail Politaev # firewallcmd-new / iptables-ipset-proto6 combined for maximum goodness