From 8bcd8ae66d1ceb69ae65e59fe4d78527c25e20a1 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 15 May 2017 17:15:07 +0200 Subject: [PATCH] saving uncommitted changes in /etc prior to emerge run --- .etckeeper | 14 ++ fail2ban/action.d/badips.conf | 4 +- fail2ban/action.d/badips.py | 21 +-- fail2ban/action.d/blocklist_de.conf | 2 +- fail2ban/action.d/cloudflare.conf | 2 + fail2ban/action.d/firewallcmd-allports.conf | 2 +- fail2ban/action.d/firewallcmd-multiport.conf | 6 +- .../action.d/firewallcmd-rich-logging.conf | 65 +++++++++ fail2ban/action.d/firewallcmd-rich-rules.conf | 57 ++++++++ fail2ban/action.d/mynetwatchman.conf | 8 +- fail2ban/action.d/nftables-allports.conf | 22 +++ fail2ban/action.d/nftables-common.conf | 119 ++++++++++++++++ fail2ban/action.d/nftables-multiport.conf | 22 +++ fail2ban/action.d/npf.conf | 61 +++++++++ fail2ban/action.d/route.conf | 3 + fail2ban/filter.d/apache-badbots.conf | 2 +- fail2ban/filter.d/apache-modsecurity.conf | 3 +- fail2ban/filter.d/assp.conf | 33 ++++- fail2ban/filter.d/asterisk.conf | 23 ++-- fail2ban/filter.d/botsearch-common.conf | 4 +- fail2ban/filter.d/common.conf | 10 +- fail2ban/filter.d/courier-smtp.conf | 2 +- fail2ban/filter.d/dovecot.conf | 13 +- fail2ban/filter.d/exim-common.conf | 4 +- fail2ban/filter.d/exim.conf | 12 +- fail2ban/filter.d/freeswitch.conf | 2 +- fail2ban/filter.d/haproxy-http-auth.conf | 37 +++++ .../ignorecommands/apache-fakegooglebot | 7 +- fail2ban/filter.d/mongodb-auth.conf | 49 +++++++ fail2ban/filter.d/monit.conf | 15 +- fail2ban/filter.d/murmur.conf | 28 ++++ fail2ban/filter.d/mysqld-auth.conf | 2 +- fail2ban/filter.d/nginx-limit-req.conf | 45 ++++++ fail2ban/filter.d/nsd.conf | 4 +- fail2ban/filter.d/openhab.conf | 16 +++ fail2ban/filter.d/postfix-rbl.conf | 2 +- fail2ban/filter.d/postfix-sasl.conf | 4 +- fail2ban/filter.d/postfix.conf | 4 +- fail2ban/filter.d/pure-ftpd.conf | 4 + fail2ban/filter.d/screensharingd.conf | 31 +++++ fail2ban/filter.d/sendmail-reject.conf | 2 +- fail2ban/filter.d/slapd.conf | 25 ++++ fail2ban/filter.d/sshd.conf | 9 +- fail2ban/filter.d/vsftpd.conf | 2 +- fail2ban/jail.conf | 129 ++++++++++++++---- fail2ban/paths-common.conf | 19 ++- fail2ban/paths-fedora.conf | 14 +- fail2ban/paths-opensuse.conf | 50 +++++++ init.d/fail2ban | 20 ++- logrotate.d/fail2ban | 6 +- 50 files changed, 921 insertions(+), 119 deletions(-) create mode 100644 fail2ban/action.d/firewallcmd-rich-logging.conf create mode 100644 fail2ban/action.d/firewallcmd-rich-rules.conf create mode 100644 fail2ban/action.d/nftables-allports.conf create mode 100644 fail2ban/action.d/nftables-common.conf create mode 100644 fail2ban/action.d/nftables-multiport.conf create mode 100644 fail2ban/action.d/npf.conf create mode 100644 fail2ban/filter.d/haproxy-http-auth.conf create mode 100644 fail2ban/filter.d/mongodb-auth.conf create mode 100644 fail2ban/filter.d/murmur.conf create mode 100644 fail2ban/filter.d/nginx-limit-req.conf create mode 100644 fail2ban/filter.d/openhab.conf create mode 100644 fail2ban/filter.d/screensharingd.conf create mode 100644 fail2ban/filter.d/slapd.conf create mode 100644 fail2ban/paths-opensuse.conf diff --git a/.etckeeper b/.etckeeper index 3030186..0431529 100755 --- a/.etckeeper +++ b/.etckeeper @@ -1342,6 +1342,8 @@ maybe chmod 0644 'fail2ban/action.d/firewallcmd-allports.conf' maybe chmod 0644 'fail2ban/action.d/firewallcmd-ipset.conf' maybe chmod 0644 'fail2ban/action.d/firewallcmd-multiport.conf' maybe chmod 0644 'fail2ban/action.d/firewallcmd-new.conf' +maybe chmod 0644 'fail2ban/action.d/firewallcmd-rich-logging.conf' +maybe chmod 0644 'fail2ban/action.d/firewallcmd-rich-rules.conf' maybe chmod 0644 'fail2ban/action.d/hostsdeny.conf' maybe chmod 0644 'fail2ban/action.d/ipfilter.conf' maybe chmod 0644 'fail2ban/action.d/ipfw.conf' @@ -1361,6 +1363,10 @@ maybe chmod 0644 'fail2ban/action.d/mail-whois-lines.conf' maybe chmod 0644 'fail2ban/action.d/mail-whois.conf' maybe chmod 0644 'fail2ban/action.d/mail.conf' maybe chmod 0644 'fail2ban/action.d/mynetwatchman.conf' +maybe chmod 0644 'fail2ban/action.d/nftables-allports.conf' +maybe chmod 0644 'fail2ban/action.d/nftables-common.conf' +maybe chmod 0644 'fail2ban/action.d/nftables-multiport.conf' +maybe chmod 0644 'fail2ban/action.d/npf.conf' maybe chmod 0644 'fail2ban/action.d/nsupdate.conf' maybe chmod 0644 'fail2ban/action.d/osx-afctl.conf' maybe chmod 0644 'fail2ban/action.d/osx-ipfw.conf' @@ -1417,18 +1423,23 @@ maybe chmod 0644 'fail2ban/filter.d/froxlor-auth.conf' maybe chmod 0644 'fail2ban/filter.d/groupoffice.conf' maybe chmod 0644 'fail2ban/filter.d/gssftpd.conf' maybe chmod 0644 'fail2ban/filter.d/guacamole.conf' +maybe chmod 0644 'fail2ban/filter.d/haproxy-http-auth.conf' maybe chmod 0644 'fail2ban/filter.d/horde.conf' maybe chmod 0755 'fail2ban/filter.d/ignorecommands' maybe chmod 0755 'fail2ban/filter.d/ignorecommands/apache-fakegooglebot' maybe chmod 0644 'fail2ban/filter.d/kerio.conf' maybe chmod 0644 'fail2ban/filter.d/lighttpd-auth.conf' +maybe chmod 0644 'fail2ban/filter.d/mongodb-auth.conf' maybe chmod 0644 'fail2ban/filter.d/monit.conf' +maybe chmod 0644 'fail2ban/filter.d/murmur.conf' maybe chmod 0644 'fail2ban/filter.d/mysqld-auth.conf' maybe chmod 0644 'fail2ban/filter.d/nagios.conf' maybe chmod 0644 'fail2ban/filter.d/named-refused.conf' maybe chmod 0644 'fail2ban/filter.d/nginx-botsearch.conf' maybe chmod 0644 'fail2ban/filter.d/nginx-http-auth.conf' +maybe chmod 0644 'fail2ban/filter.d/nginx-limit-req.conf' maybe chmod 0644 'fail2ban/filter.d/nsd.conf' +maybe chmod 0644 'fail2ban/filter.d/openhab.conf' maybe chmod 0644 'fail2ban/filter.d/openwebmail.conf' maybe chmod 0644 'fail2ban/filter.d/oracleims.conf' maybe chmod 0644 'fail2ban/filter.d/pam-generic.conf' @@ -1443,11 +1454,13 @@ maybe chmod 0644 'fail2ban/filter.d/pure-ftpd.conf' maybe chmod 0644 'fail2ban/filter.d/qmail.conf' maybe chmod 0644 'fail2ban/filter.d/recidive.conf' maybe chmod 0644 'fail2ban/filter.d/roundcube-auth.conf' +maybe chmod 0644 'fail2ban/filter.d/screensharingd.conf' maybe chmod 0644 'fail2ban/filter.d/selinux-common.conf' maybe chmod 0644 'fail2ban/filter.d/selinux-ssh.conf' maybe chmod 0644 'fail2ban/filter.d/sendmail-auth.conf' maybe chmod 0644 'fail2ban/filter.d/sendmail-reject.conf' maybe chmod 0644 'fail2ban/filter.d/sieve.conf' +maybe chmod 0644 'fail2ban/filter.d/slapd.conf' maybe chmod 0644 'fail2ban/filter.d/sogo-auth.conf' maybe chmod 0644 'fail2ban/filter.d/solid-pop3d.conf' maybe chmod 0644 'fail2ban/filter.d/squid.conf' @@ -1471,6 +1484,7 @@ maybe chmod 0644 'fail2ban/paths-common.conf' maybe chmod 0644 'fail2ban/paths-debian.conf' maybe chmod 0644 'fail2ban/paths-fedora.conf' maybe chmod 0644 'fail2ban/paths-freebsd.conf' +maybe chmod 0644 'fail2ban/paths-opensuse.conf' maybe chmod 0644 'fail2ban/paths-osx.conf' maybe chmod 0644 'filesystems' maybe chmod 0755 'fonts' diff --git a/fail2ban/action.d/badips.conf b/fail2ban/action.d/badips.conf index 4a5c0f9..6f9513f 100644 --- a/fail2ban/action.d/badips.conf +++ b/fail2ban/action.d/badips.conf @@ -1,6 +1,6 @@ # Fail2ban reporting to badips.com # -# Note: This reports and IP only and does not actually ban traffic. Use +# Note: This reports an IP only and does not actually ban traffic. Use # another action in the same jail if you want bans to occur. # # Set the category to the appropriate value before use. @@ -10,7 +10,7 @@ [Definition] -actionban = curl --fail --user-agent "fail2ban v0.8.12" http://www.badips.com/add// +actionban = curl --fail --user-agent "" http://www.badips.com/add// [Init] diff --git a/fail2ban/action.d/badips.py b/fail2ban/action.d/badips.py index a1df00a..4bc879a 100644 --- a/fail2ban/action.d/badips.py +++ b/fail2ban/action.d/badips.py @@ -21,7 +21,6 @@ import sys if sys.version_info < (2, 7): raise ImportError("badips.py action requires Python >= 2.7") import json -from functools import partial import threading import logging if sys.version_info >= (3, ): @@ -33,7 +32,6 @@ else: from urllib import urlencode from fail2ban.server.actions import ActionBase -from fail2ban.version import version as f2bVersion class BadIPsAction(ActionBase): @@ -72,6 +70,9 @@ class BadIPsAction(ActionBase): updateperiod : int, optional Time in seconds between updating bad IPs blacklist. Default 900 (15 minutes) + agent : str, optional + User agent transmitted to server. + Default `Fail2Ban/ver.` Raises ------ @@ -79,14 +80,18 @@ class BadIPsAction(ActionBase): If invalid `category`, `score`, `banaction` or `updateperiod`. """ + TIMEOUT = 10 _badips = "http://www.badips.com" - _Request = partial( - Request, headers={'User-Agent': "Fail2Ban %s" % f2bVersion}) + def _Request(self, url, **argv): + return Request(url, headers={'User-Agent': self.agent}, **argv) def __init__(self, jail, name, category, score=3, age="24h", key=None, - banaction=None, bancategory=None, bankey=None, updateperiod=900): + banaction=None, bancategory=None, bankey=None, updateperiod=900, agent="Fail2Ban", + timeout=TIMEOUT): super(BadIPsAction, self).__init__(jail, name) + self.timeout = timeout + self.agent = agent self.category = category self.score = score self.age = age @@ -117,7 +122,7 @@ class BadIPsAction(ActionBase): """ try: response = urlopen( - self._Request("/".join([self._badips, "get", "categories"]))) + self._Request("/".join([self._badips, "get", "categories"])), timeout=self.timeout) except HTTPError as response: messages = json.loads(response.read().decode('utf-8')) self._logSys.error( @@ -171,7 +176,7 @@ class BadIPsAction(ActionBase): urlencode({'age': age})]) if key: url = "&".join([url, urlencode({'key': key})]) - response = urlopen(self._Request(url)) + response = urlopen(self._Request(url), timeout=self.timeout) except HTTPError as response: messages = json.loads(response.read().decode('utf-8')) self._logSys.error( @@ -356,7 +361,7 @@ class BadIPsAction(ActionBase): url = "/".join([self._badips, "add", self.category, aInfo['ip']]) if self.key: url = "?".join([url, urlencode({'key': self.key})]) - response = urlopen(self._Request(url)) + response = urlopen(self._Request(url), timeout=self.timeout) except HTTPError as response: messages = json.loads(response.read().decode('utf-8')) self._logSys.error( diff --git a/fail2ban/action.d/blocklist_de.conf b/fail2ban/action.d/blocklist_de.conf index 6d52069..2f31d8b 100644 --- a/fail2ban/action.d/blocklist_de.conf +++ b/fail2ban/action.d/blocklist_de.conf @@ -54,7 +54,7 @@ actioncheck = # Tags: See jail.conf(5) man page # Values: CMD # -actionban = curl --fail --data-urlencode 'server=' --data 'apikey=' --data 'service=' --data 'ip=' --data-urlencode 'logs=' --data 'format=text' --user-agent "fail2ban v0.8.12" "https://www.blocklist.de/en/httpreports.html" +actionban = curl --fail --data-urlencode 'server=' --data 'apikey=' --data 'service=' --data 'ip=' --data-urlencode 'logs=' --data 'format=text' --user-agent "" "https://www.blocklist.de/en/httpreports.html" # Option: actionunban # Notes.: command executed when unbanning an IP. Take care that the diff --git a/fail2ban/action.d/cloudflare.conf b/fail2ban/action.d/cloudflare.conf index 4bc90c9..aa87163 100644 --- a/fail2ban/action.d/cloudflare.conf +++ b/fail2ban/action.d/cloudflare.conf @@ -9,6 +9,8 @@ # Referenced from http://www.normyee.net/blog/2012/02/02/adding-cloudflare-support-to-fail2ban by NORM YEE # # To get your CloudFlare API Key: https://www.cloudflare.com/a/account/my-account +# +# CloudFlare API error codes: https://www.cloudflare.com/docs/host-api.html#s4.2 [Definition] diff --git a/fail2ban/action.d/firewallcmd-allports.conf b/fail2ban/action.d/firewallcmd-allports.conf index ec52bab..571d5ba 100644 --- a/fail2ban/action.d/firewallcmd-allports.conf +++ b/fail2ban/action.d/firewallcmd-allports.conf @@ -6,7 +6,7 @@ [INCLUDES] -before = iptables-blocktype.conf +before = iptables-common.conf [Definition] diff --git a/fail2ban/action.d/firewallcmd-multiport.conf b/fail2ban/action.d/firewallcmd-multiport.conf index 4d806e6..438d4cf 100644 --- a/fail2ban/action.d/firewallcmd-multiport.conf +++ b/fail2ban/action.d/firewallcmd-multiport.conf @@ -5,15 +5,15 @@ [INCLUDES] -before = iptables-blocktype.conf +before = iptables-common.conf [Definition] actionstart = firewall-cmd --direct --add-chain ipv4 filter f2b- firewall-cmd --direct --add-rule ipv4 filter f2b- 1000 -j RETURN - firewall-cmd --direct --add-rule ipv4 filter 0 -m state --state NEW -p -m multiport --dports -j f2b- + firewall-cmd --direct --add-rule ipv4 filter 0 -m conntrack --ctstate NEW -p -m multiport --dports -j f2b- -actionstop = firewall-cmd --direct --remove-rule ipv4 filter 0 -m state --state NEW -p -m multiport --dports -j f2b- +actionstop = firewall-cmd --direct --remove-rule ipv4 filter 0 -m conntrack --ctstate NEW -p -m multiport --dports -j f2b- firewall-cmd --direct --remove-rules ipv4 filter f2b- firewall-cmd --direct --remove-chain ipv4 filter f2b- diff --git a/fail2ban/action.d/firewallcmd-rich-logging.conf b/fail2ban/action.d/firewallcmd-rich-logging.conf new file mode 100644 index 0000000..1b88c2d --- /dev/null +++ b/fail2ban/action.d/firewallcmd-rich-logging.conf @@ -0,0 +1,65 @@ +# Fail2Ban configuration file +# +# Author: Donald Yandt +# +# Because of the rich rule commands requires firewalld-0.3.1+ +# This action uses firewalld rich-rules which gives you a cleaner iptables since it stores rules according to zones and not +# by chain. So for an example all deny rules will be listed under _deny and all log rules under _log. +# +# Also this action logs banned access attempts so you can filter that and increase ban time for offenders. +# +# If you use the --permanent rule you get a xml file in /etc/firewalld/zones/.xml that can be shared and parsed easliy +# +# Example commands to view rules: +# firewall-cmd [--zone=] --list-rich-rules +# firewall-cmd [--zone=] --list-all +# firewall-cmd [--zone=zone] --query-rich-rule='rule' + +[Definition] + +actionstart = + +actionstop = + +actioncheck = + +# you can also use zones and/or service names. +# +# zone example: +# firewall-cmd --zone= --add-rich-rule="rule family='ipv4' source address='' port port='' protocol='' log prefix='f2b-' level='' limit value='/m' " +# service name example: +# firewall-cmd --zone= --add-rich-rule="rule family='ipv4' source address='' service name='' log prefix='f2b-' level='' limit value='/m' " +# Because rich rules can only handle single or a range of ports we must split ports and execute the command for each port. Ports can be single and ranges seperated by a comma or space for an example: http, https, 22-60, 18 smtp + +actionban = ports=""; for p in $(echo $ports | tr ", " " "); do firewall-cmd --add-rich-rule="rule family='ipv4' source address='' port port='$p' protocol='' log prefix='f2b-' level='' limit value='/m' "; done + +actionunban = ports=""; for p in $(echo $ports | tr ", " " "); do firewall-cmd --remove-rich-rule="rule family='ipv4' source address='' port port='$p' protocol='' log prefix='f2b-' level='' limit value='/m' "; done + +[Init] + +name = default + +# log levels are "emerg", "alert", "crit", "error", "warning", "notice", "info" or "debug" +level = info + +# log rate per minute +rate = 1 + +zone = public + +# use command firewall-cmd --get-services to see a list of services available +# +# Examples: +# +# amanda-client amanda-k5-client bacula bacula-client dhcp dhcpv6 dhcpv6-client dns freeipa-ldap freeipa-ldaps +# freeipa-replication ftp high-availability http https imaps ipp ipp-client ipsec iscsi-target kadmin kerberos +# kpasswd ldap ldaps libvirt libvirt-tls mdns mosh mountd ms-wbt mysql nfs ntp openvpn pmcd pmproxy pmwebapi pmwebapis pop3s +# postgresql privoxy proxy-dhcp puppetmaster radius rpc-bind rsyncd samba samba-client sane smtp squid ssh synergy +# telnet tftp tftp-client tinc tor-socks transmission-client vdsm vnc-server wbem-https xmpp-bosh xmpp-client xmpp-local xmpp-server + +service = ssh + +# reject types: 'icmp-net-unreachable', 'icmp-host-unreachable', 'icmp-port-unreachable', 'icmp-proto-unreachable', +# 'icmp-net-prohibited', 'icmp-host-prohibited', 'icmp-admin-prohibited' or 'tcp-reset' + +blocktype = reject type='icmp-port-unreachable' diff --git a/fail2ban/action.d/firewallcmd-rich-rules.conf b/fail2ban/action.d/firewallcmd-rich-rules.conf new file mode 100644 index 0000000..4e39df5 --- /dev/null +++ b/fail2ban/action.d/firewallcmd-rich-rules.conf @@ -0,0 +1,57 @@ +# Fail2Ban configuration file +# +# Author: Donald Yandt +# +# Because of the rich rule commands requires firewalld-0.3.1+ +# This action uses firewalld rich-rules which gives you a cleaner iptables since it stores rules according to zones and not +# by chain. So for an example all deny rules will be listed under _deny. +# +# If you use the --permanent rule you get a xml file in /etc/firewalld/zones/.xml that can be shared and parsed easliy +# +# Example commands to view rules: +# firewall-cmd [--zone=] --list-rich-rules +# firewall-cmd [--zone=] --list-all +# firewall-cmd [--zone=zone] --query-rich-rule='rule' + +[Definition] + +actionstart = + +actionstop = + +actioncheck = + +#you can also use zones and/or service names. +# +# zone example: +# firewall-cmd --zone= --add-rich-rule="rule family='ipv4' source address='' port port='' protocol='' " +# service name example: +# firewall-cmd --zone= --add-rich-rule="rule family='ipv4' source address='' service name='' " +# Because rich rules can only handle single or a range of ports we must split ports and execute the command for each port. Ports can be single and ranges seperated by a comma or space for an example: http, https, 22-60, 18 smtp + +actionban = ports=""; for p in $(echo $ports | tr ", " " "); do firewall-cmd --add-rich-rule="rule family='ipv4' source address='' port port='$p' protocol='' "; done + +actionunban = ports=""; for p in $(echo $ports | tr ", " " "); do firewall-cmd --remove-rich-rule="rule family='ipv4' source address='' port port='$p' protocol='' "; done + +[Init] + +name = default + +zone = public + +# use command firewall-cmd --get-services to see a list of services available +# +# Examples: +# +# amanda-client amanda-k5-client bacula bacula-client dhcp dhcpv6 dhcpv6-client dns freeipa-ldap freeipa-ldaps +# freeipa-replication ftp high-availability http https imaps ipp ipp-client ipsec iscsi-target kadmin kerberos +# kpasswd ldap ldaps libvirt libvirt-tls mdns mosh mountd ms-wbt mysql nfs ntp openvpn pmcd pmproxy pmwebapi pmwebapis pop3s +# postgresql privoxy proxy-dhcp puppetmaster radius rpc-bind rsyncd samba samba-client sane smtp squid ssh synergy +# telnet tftp tftp-client tinc tor-socks transmission-client vdsm vnc-server wbem-https xmpp-bosh xmpp-client xmpp-local xmpp-server + +service = ssh + +# reject types: 'icmp-net-unreachable', 'icmp-host-unreachable', 'icmp-port-unreachable', 'icmp-proto-unreachable', +# 'icmp-net-prohibited', 'icmp-host-prohibited', 'icmp-admin-prohibited' or 'tcp-reset' + +blocktype = reject type='icmp-port-unreachable' diff --git a/fail2ban/action.d/mynetwatchman.conf b/fail2ban/action.d/mynetwatchman.conf index fbb8a8f..e3395d5 100644 --- a/fail2ban/action.d/mynetwatchman.conf +++ b/fail2ban/action.d/mynetwatchman.conf @@ -111,13 +111,17 @@ myip = `ip -4 addr show dev eth0 | grep inet | head -n 1 | sed -r 's/.*inet ([0- # protocol = tcp +# Option: agent +# Default: Fail2ban +agent = Fail2ban + # Option: getcmd # Notes.: A command to fetch a URL. Should output page to STDOUT # Values: CMD Default: wget # -getcmd = wget --no-verbose --tries=3 --waitretry=10 --connect-timeout=10 --read-timeout=60 --retry-connrefused --output-document=- --user-agent=Fail2Ban +getcmd = wget --no-verbose --tries=3 --waitretry=10 --connect-timeout=10 --read-timeout=60 --retry-connrefused --output-document=- --user-agent= # Alternative value: -# getcmd = curl --silent --show-error --retry 3 --connect-timeout 10 --max-time 60 --user-agent Fail2Ban +# getcmd = curl --silent --show-error --retry 3 --connect-timeout 10 --max-time 60 --user-agent # Option: srcport # Notes.: The source port of the attack. You're unlikely to have this info, so diff --git a/fail2ban/action.d/nftables-allports.conf b/fail2ban/action.d/nftables-allports.conf new file mode 100644 index 0000000..afd0ca8 --- /dev/null +++ b/fail2ban/action.d/nftables-allports.conf @@ -0,0 +1,22 @@ +# Fail2Ban configuration file +# +# Author: Cyril Jaquier +# Modified: Yaroslav O. Halchenko +# made active on all ports from original iptables.conf +# Modified: Alexander Belykh +# adapted for nftables +# + +[INCLUDES] + +before = nftables-common.conf + +[Definition] + +# Option: nftables_mode +# Notes.: additional expressions for nftables filter rule +# Values: nftables expressions +# +nftables_mode = ip protocol + +[Init] diff --git a/fail2ban/action.d/nftables-common.conf b/fail2ban/action.d/nftables-common.conf new file mode 100644 index 0000000..80657c5 --- /dev/null +++ b/fail2ban/action.d/nftables-common.conf @@ -0,0 +1,119 @@ +# Fail2Ban configuration file +# +# Author: Daniel Black +# Author: Cyril Jaquier +# Modified: Yaroslav O. Halchenko +# made active on all ports from original iptables.conf +# Modified: Alexander Belykh +# adapted for nftables +# +# This is a included configuration file and includes the definitions for the nftables +# used in all nftables based actions by default. +# +# The user can override the defaults in nftables-common.local + +[INCLUDES] + +after = nftables-common.local + +[Definition] + +# Option: nftables_mode +# Notes.: additional expressions for nftables filter rule +# Values: nftables expressions +# +nftables_mode = dport \{ \} + +# Option: actionstart +# Notes.: command executed once at the start of Fail2Ban. +# Values: CMD +# +actionstart = add set f2b- \{ type \; \} + insert rule %(nftables_mode)s ip saddr @f2b- + +_nft_list = --handle --numeric list chain +_nft_get_handle_id = grep -m1 'ip saddr @f2b- # handle' | grep -oe ' handle [0-9]*' + +# Option: actionstop +# Notes.: command executed once at the end of Fail2Ban +# Values: CMD +# +actionstop = HANDLE_ID=$(%(_nft_list)s | %(_nft_get_handle_id)s) + delete rule $HANDLE_ID + delete set f2b- + +# Option: actioncheck +# Notes.: command executed once before each actionban command +# Values: CMD +# +actioncheck = list chain | grep -q '@f2b-[ \t]' + +# Option: actionban +# Notes.: command executed when banning an IP. Take care that the +# command is executed with Fail2Ban user rights. +# Tags: See jail.conf(5) man page +# Values: CMD +# +actionban = add element f2b- \{ \} + +# Option: actionunban +# Notes.: command executed when unbanning an IP. Take care that the +# command is executed with Fail2Ban user rights. +# Tags: See jail.conf(5) man page +# Values: CMD +# +actionunban = delete element f2b- \{ \} + +[Init] + +# Option: nftables_type +# Notes.: address type to work with +# Values: [ipv4_addr | ipv6_addr] Default: ipv4_addr +# +nftables_type = ipv4_addr + +# Option: nftables_family +# Notes.: address family to work in +# Values: [ip | ip6 | inet] Default: inet +# +nftables_family = inet + +# Option: nftables_table +# Notes.: table in the address family to work in +# Values: STRING Default: filter +# +nftables_table = filter + +# Option: chain +# Notes specifies the nftables chain to which the Fail2Ban rules should be +# added +# Values: STRING Default: input +chain = input + +# Default name of the filtering set +# +name = default + +# Option: port +# Notes.: specifies port to monitor +# Values: [ NUM | STRING ] Default: +# +port = ssh + +# Option: protocol +# Notes.: internally used by config reader for interpolations. +# Values: [ tcp | udp ] Default: tcp +# +protocol = tcp + +# Option: blocktype +# Note: This is what the action does with rules. This can be any jump target +# as per the nftables man page (section 8). Common values are drop +# reject, reject with icmp type host-unreachable +# Values: STRING +blocktype = reject + +# Option: nftables +# Notes.: Actual command to be executed, including common to all calls options +# Values: STRING +nftables = nft diff --git a/fail2ban/action.d/nftables-multiport.conf b/fail2ban/action.d/nftables-multiport.conf new file mode 100644 index 0000000..d1afafb --- /dev/null +++ b/fail2ban/action.d/nftables-multiport.conf @@ -0,0 +1,22 @@ +# Fail2Ban configuration file +# +# Author: Cyril Jaquier +# Modified: Yaroslav O. Halchenko +# made active on all ports from original iptables.conf +# Modified: Alexander Belykh +# adapted for nftables +# + +[INCLUDES] + +before = nftables-common.conf + +[Definition] + +# Option: nftables_mode +# Notes.: additional expressions for nftables filter rule +# Values: nftables expressions +# +nftables_mode = dport \{ \} + +[Init] diff --git a/fail2ban/action.d/npf.conf b/fail2ban/action.d/npf.conf new file mode 100644 index 0000000..8b00d17 --- /dev/null +++ b/fail2ban/action.d/npf.conf @@ -0,0 +1,61 @@ +# Fail2Ban configuration file +# +# NetBSD npf ban/unban +# +# Author: Nils Ratusznik +# Based on pf.conf action file +# + +[Definition] + +# Option: actionstart +# Notes.: command executed once at the start of Fail2Ban. +# Values: CMD +# +# we don't enable NPF automatically, as it will be enabled elsewhere +actionstart = + + +# Option: actionstop +# Notes.: command executed once at the end of Fail2Ban +# Values: CMD +# +# we don't disable NPF automatically either +actionstop = + + +# Option: actioncheck +# Notes.: command executed once before each actionban command +# Values: CMD +# +actioncheck = + + +# Option: actionban +# Notes.: command executed when banning an IP. Take care that the +# command is executed with Fail2Ban user rights. +# Tags: IP address +# number of failures +#