File: Limit

package info (click to toggle)
shorewall 3.2.6-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,508 kB
  • ctags: 288
  • sloc: sh: 12,774; makefile: 66
file content (22 lines) | stat: -rw-r--r-- 754 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#
# Shorewall version 3.2 -- Extension Script to create Limit action.
#
# /usr/share/shorewall/Limit
##############################################################################

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