From 52e4d0af41416d960c448e3b0b828c662c1fd984 Mon Sep 17 00:00:00 2001 From: teastep Date: Wed, 6 Sep 2006 16:28:52 +0000 Subject: [PATCH] Add Debian warning and implementation details to 'Limit' documentation git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@4527 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb --- docs/PortKnocking.xml | 50 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/docs/PortKnocking.xml b/docs/PortKnocking.xml index 85732e6a1..65cc4d781 100644 --- a/docs/PortKnocking.xml +++ b/docs/PortKnocking.xml @@ -133,6 +133,14 @@ SSHKnock net loc:192.168.1.5 tcp 22 -
Limiting Per-IP Connection Rate + + Debian users. This feature is broken in the Debian version 3.0.7 + of Shorewall (and possibly in other versions). The file + /usr/share/shorewall/Limit was inadvertently + dropped from the .deb. That file may be obtained from Shorewall SVN and installed manually. + + Beginning with Shorewall 3.0.4, Shorewall has a 'Limit' action. Limit is invoked with a comma-separated list in place of a logging tag. The list has three elements: @@ -191,5 +199,47 @@ Limit:info:SSHA,3,60 net $FW tcp 22 + +
+ How Limit is Implemented + + For those who are curious, the Limit action is implemented in + Shorewall 3.0 and Shorewall 3.2 as follows: + + + + The file + /usr/share/shorewall/action.Limit is + empty. + + + + The file /usr/share/shorewall/Limit is as + follows: + + set -- $(separate_list $TAG) + +[ $# -eq 3 ] || fatal_error "Rule must include <set name>,<max connections>,<interval> as the log tag" + +run_iptables -A $CHAIN -m recent --name $1 --set + +if [ -n "$LEVEL" ]; then + run_iptables -N $CHAIN% + log_rule_limit $LEVEL $CHAIN% $1 DROP "" "" -A + run_iptables -A $CHAIN% -j DROP + run_iptables -A $CHAIN -m recent --name $1 --update --seconds $3 --hitcount $(( $2 + 1 )) -j $CHAIN% +else + run_iptables -A $CHAIN -m recent --update --name $1 --seconds $3 --hitcount $(( $2 + 1 )) -j DROP +fi + +run_iptables -A $CHAIN -j ACCEPT + + + + + In Shorewall 3.3, Limit is made into a built-in action; basically + that means that the above code now lives inside of Shorewall rather than + in a separate file. +
\ No newline at end of file