diff --git a/ChangeLog b/ChangeLog index 9aedd52a..74da8efa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -106,6 +106,8 @@ fail2ban-users mailing list and IRC. source. Also include BSD changes. * [1d9abd1] Action files can have tags in definition that refer to other tags. + * [10886e7,cec5da2,adb991a] Change actions to response with ICMP port + unreachable rather than just a drop of the packet. Pascal Borreli * [a2b29b4] Fixed lots of typos in config files and documentation. hamilton5 diff --git a/MANIFEST b/MANIFEST index 62da3040..765a9a7d 100644 --- a/MANIFEST +++ b/MANIFEST @@ -98,6 +98,7 @@ config/filter.d/lighttpd-auth.conf config/filter.d/recidive.conf config/filter.d/roundcube-auth.conf config/action.d/dummy.conf +config/action.d/iptables-blocktype.conf config/action.d/iptables-ipset-proto4.conf config/action.d/iptables-ipset-proto6.conf config/action.d/iptables-xt_recent-echo.conf diff --git a/config/action.d/ipfilter.conf b/config/action.d/ipfilter.conf index d77de9bf..61420e38 100644 --- a/config/action.d/ipfilter.conf +++ b/config/action.d/ipfilter.conf @@ -37,7 +37,7 @@ actioncheck = # Tags: See jail.conf(5) man page # Values: CMD # -actionban = echo block in quick from /32 | /sbin/ipf -f - +actionban = echo block in quick from /32 | /sbin/ipf -f - # Option: actionunban @@ -47,7 +47,12 @@ actionban = echo block in quick from /32 | /sbin/ipf -f - # Values: CMD # # note -r option used to remove matching rule -actionunban = echo block in quick from /32 | /sbin/ipf -r -f - +actionunban = echo block in quick from /32 | /sbin/ipf -r -f - [Init] +# Option: Blocktype +# Notes : This is the return-icmp[return-code] mentioned in the ipf man page section 5. Keep this quoted to prevent +# Shell expansion. This should be blank (unquoted) to drop the packet. +# Values: STRING +blocktype = "return-icmp(port-unr)" diff --git a/config/action.d/ipfw.conf b/config/action.d/ipfw.conf index 3a56415d..09045815 100644 --- a/config/action.d/ipfw.conf +++ b/config/action.d/ipfw.conf @@ -34,7 +34,7 @@ actioncheck = # Tags: See jail.conf(5) man page # Values: CMD # -actionban = ipfw add deny tcp from to +actionban = ipfw add tcp from to # Option: actionunban @@ -58,3 +58,11 @@ port = ssh # Values: IP # localhost = 127.0.0.1 + + +# Option: blocktype +# Notes.: How to block the traffic. Use a action from man 5 ipfw +# Common values: deny, unreach port, reset +# Values: STRING +# +blocktype = unreach port diff --git a/config/action.d/iptables-allports.conf b/config/action.d/iptables-allports.conf index 50f49d82..91d40711 100644 --- a/config/action.d/iptables-allports.conf +++ b/config/action.d/iptables-allports.conf @@ -6,6 +6,11 @@ # # +[INCLUDES] + +before = iptables-blocktype.conf + + [Definition] # Option: actionstart @@ -36,7 +41,7 @@ actioncheck = iptables -n -L | grep -q 'fail2ban-[ \t]' # Tags: See jail.conf(5) man page # Values: CMD # -actionban = iptables -I fail2ban- 1 -s -j DROP +actionban = iptables -I fail2ban- 1 -s -j # Option: actionunban # Notes.: command executed when unbanning an IP. Take care that the @@ -44,7 +49,7 @@ actionban = iptables -I fail2ban- 1 -s -j DROP # Tags: See jail.conf(5) man page # Values: CMD # -actionunban = iptables -D fail2ban- -s -j DROP +actionunban = iptables -D fail2ban- -s -j [Init] diff --git a/config/action.d/iptables-blocktype.conf b/config/action.d/iptables-blocktype.conf new file mode 100644 index 00000000..c505e49c --- /dev/null +++ b/config/action.d/iptables-blocktype.conf @@ -0,0 +1,22 @@ +# Fail2Ban configuration file +# +# Author: Daniel Black +# +# This is a included configuration file and includes the defination for the blocktype +# used in all iptables based actions by default. +# +# The user can override the default in iptables-blocktype.local + +[INCLUDES] + +after = iptables-blocktype.local + +[Init] + +# Option: blocktype +# Note: This is what the action does with rules. This can be any jump target +# as per the iptables man page (section 8). Common values are DROP +# REJECT, REJECT --reject-with icmp-port-unreachable +# Values: STRING +blocktype = REJECT --reject-with icmp-port-unreachable + diff --git a/config/action.d/iptables-ipset-proto4.conf b/config/action.d/iptables-ipset-proto4.conf index 4221dd8d..3ed778f9 100644 --- a/config/action.d/iptables-ipset-proto4.conf +++ b/config/action.d/iptables-ipset-proto4.conf @@ -18,6 +18,10 @@ # apt-get install ipset xtables-addons-source # module-assistant auto-install xtables-addons +[INCLUDES] + +before = iptables-blocktype.conf + [Definition] # Option: actionstart @@ -25,13 +29,13 @@ # Values: CMD # actionstart = ipset --create fail2ban- iphash - iptables -I INPUT -p -m multiport --dports -m set --match-set fail2ban- src -j DROP + iptables -I INPUT -p -m multiport --dports -m set --match-set fail2ban- src -j # Option: actionstop # Notes.: command executed once at the end of Fail2Ban # Values: CMD # -actionstop = iptables -D INPUT -p -m multiport --dports -m set --match-set fail2ban- src -j DROP +actionstop = iptables -D INPUT -p -m multiport --dports -m set --match-set fail2ban- src -j ipset --flush fail2ban- ipset --destroy fail2ban- @@ -68,4 +72,3 @@ port = ssh # Values: [ tcp | udp | icmp | all ] Default: tcp # protocol = tcp - diff --git a/config/action.d/iptables-ipset-proto6.conf b/config/action.d/iptables-ipset-proto6.conf index d90acd44..3cf9b140 100644 --- a/config/action.d/iptables-ipset-proto6.conf +++ b/config/action.d/iptables-ipset-proto6.conf @@ -18,6 +18,11 @@ # apt-get install ipset xtables-addons-source # module-assistant auto-install xtables-addons +[INCLUDES] + +before = iptables-blocktype.conf + + [Definition] # Option: actionstart @@ -74,5 +79,3 @@ protocol = tcp # Values: [ NUM ] Default: 600 bantime = 600 - - diff --git a/config/action.d/iptables-multiport-log.conf b/config/action.d/iptables-multiport-log.conf index b79983fc..6084cb6c 100644 --- a/config/action.d/iptables-multiport-log.conf +++ b/config/action.d/iptables-multiport-log.conf @@ -9,6 +9,10 @@ # # +[INCLUDES] + +before = iptables-blocktype.conf + [Definition] # Option: actionstart @@ -20,7 +24,7 @@ actionstart = iptables -N fail2ban- iptables -I 1 -p -m multiport --dports -j fail2ban- iptables -N fail2ban--log iptables -I fail2ban--log -j LOG --log-prefix "$(expr fail2ban- : '\(.\{1,23\}\)'):DROP " --log-level warning -m limit --limit 6/m --limit-burst 2 - iptables -A fail2ban--log -j DROP + iptables -A fail2ban--log -j # Option: actionstop # Notes.: command executed once at the end of Fail2Ban diff --git a/config/action.d/iptables-multiport.conf b/config/action.d/iptables-multiport.conf index f799289f..daa31148 100644 --- a/config/action.d/iptables-multiport.conf +++ b/config/action.d/iptables-multiport.conf @@ -4,6 +4,10 @@ # Modified by Yaroslav Halchenko for multiport banning # +[INCLUDES] + +before = iptables-blocktype.conf + [Definition] # Option: actionstart @@ -34,7 +38,7 @@ actioncheck = iptables -n -L | grep -q 'fail2ban-[ \t]' # Tags: See jail.conf(5) man page # Values: CMD # -actionban = iptables -I fail2ban- 1 -s -j DROP +actionban = iptables -I fail2ban- 1 -s -j # Option: actionunban # Notes.: command executed when unbanning an IP. Take care that the @@ -42,7 +46,7 @@ actionban = iptables -I fail2ban- 1 -s -j DROP # Tags: See jail.conf(5) man page # Values: CMD # -actionunban = iptables -D fail2ban- -s -j DROP +actionunban = iptables -D fail2ban- -s -j [Init] diff --git a/config/action.d/iptables-new.conf b/config/action.d/iptables-new.conf index f22916e1..38927442 100644 --- a/config/action.d/iptables-new.conf +++ b/config/action.d/iptables-new.conf @@ -6,6 +6,11 @@ # # +[INCLUDES] + +before = iptables-blocktype.conf + + [Definition] # Option: actionstart @@ -36,7 +41,7 @@ actioncheck = iptables -n -L | grep -q 'fail2ban-[ \t]' # Tags: See jail.conf(5) man page # Values: CMD # -actionban = iptables -I fail2ban- 1 -s -j DROP +actionban = iptables -I fail2ban- 1 -s -j # Option: actionunban # Notes.: command executed when unbanning an IP. Take care that the @@ -44,7 +49,7 @@ actionban = iptables -I fail2ban- 1 -s -j DROP # Tags: See jail.conf(5) man page # Values: CMD # -actionunban = iptables -D fail2ban- -s -j DROP +actionunban = iptables -D fail2ban- -s -j [Init] diff --git a/config/action.d/iptables-xt_recent-echo.conf b/config/action.d/iptables-xt_recent-echo.conf index 4fb397a2..829d4c06 100644 --- a/config/action.d/iptables-xt_recent-echo.conf +++ b/config/action.d/iptables-xt_recent-echo.conf @@ -4,6 +4,11 @@ # # +[INCLUDES] + +before = iptables-blocktype.conf + + [Definition] # Option: actionstart @@ -28,7 +33,7 @@ # own rules. The 3600 second timeout is independent and acts as a # safeguard in case the fail2ban process dies unexpectedly. The # shorter of the two timeouts actually matters. -actionstart = iptables -I INPUT -m recent --update --seconds 3600 --name fail2ban- -j DROP +actionstart = iptables -I INPUT -m recent --update --seconds 3600 --name fail2ban- -j # Option: actionstop # Notes.: command executed once at the end of Fail2Ban diff --git a/config/action.d/iptables.conf b/config/action.d/iptables.conf index 662b41c0..370e4731 100644 --- a/config/action.d/iptables.conf +++ b/config/action.d/iptables.conf @@ -4,6 +4,10 @@ # # +[INCLUDES] + +before = iptables-blocktype.conf + [Definition] # Option: actionstart @@ -34,7 +38,7 @@ actioncheck = iptables -n -L | grep -q 'fail2ban-[ \t]' # Tags: See jail.conf(5) man page # Values: CMD # -actionban = iptables -I fail2ban- 1 -s -j DROP +actionban = iptables -I fail2ban- 1 -s -j # Option: actionunban # Notes.: command executed when unbanning an IP. Take care that the @@ -42,7 +46,7 @@ actionban = iptables -I fail2ban- 1 -s -j DROP # Tags: See jail.conf(5) man page # Values: CMD # -actionunban = iptables -D fail2ban- -s -j DROP +actionunban = iptables -D fail2ban- -s -j [Init] diff --git a/config/action.d/route.conf b/config/action.d/route.conf index ec940b74..bb4ec8e1 100644 --- a/config/action.d/route.conf +++ b/config/action.d/route.conf @@ -15,11 +15,10 @@ # - Blocking is per IP and NOT per service, but ideal as action against ssh password bruteforcing hosts [Definition] -actionban = ip route add -actionunban = ip route del +actionban = ip route add +actionunban = ip route del -# Type of blocking -# -# Type can be blackhole, unreachable and prohibit. Unreachable and prohibit correspond to the ICMP reject messages. - -type = blackhole +# Option: blocktype +# Note: Type can be blackhole, unreachable and prohibit. Unreachable and prohibit correspond to the ICMP reject messages. +# Values: STRING +blocktype = unreachable diff --git a/config/action.d/shorewall.conf b/config/action.d/shorewall.conf index 31c1dce5..b165c701 100644 --- a/config/action.d/shorewall.conf +++ b/config/action.d/shorewall.conf @@ -38,7 +38,7 @@ actioncheck = # Tags: See jail.conf(5) man page # Values: CMD # -actionban = shorewall drop +actionban = shorewall # Option: actionunban # Notes.: command executed when unbanning an IP. Take care that the @@ -47,3 +47,9 @@ actionban = shorewall drop # Values: CMD # actionunban = shorewall allow + +# Option: blocktype +# Note: This is what the action does with rules. +# See man page of shorewall for options that include drop, logdrop, reject, or logreject +# Values: STRING +blocktype = reject