Role ipt-server: configurable rate for the new-TCP-connection limit; new defaults.
- Sync ipt-firewall-server, ip6t-firewall-server and default_settings.conf with firewall/ipt-server affa35d: new limit_new_tcp_connections_per_seconds_rate (default 30, burst twice the rate); the rule now only drops SYNs above the limit instead of accepting those below it; several IPv6 fixes. - defaults: fw_limit_new_tcp_connections_per_seconds_per_source_IP: false, fw_limit_new_tcp_connections_per_seconds_ports: "80,110,143,443,465,995", new fw_limit_new_tcp_connections_per_seconds_rate (overridable with _v6). - templates, extract-fw-host-vars.py, README: new variable and defaults. - oolm-shop: drop fw_limit_new_tcp_connections_per_seconds_per_source_IP_v6 (it would have enabled the limit for IPv6 with the new default ports). - piwik: fw_manage_config: true, per_IP_connection_limit 501, no new-connection limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1210,41 +1210,55 @@ echononl "\tLimit new (syn) TCP connections per second per source IP (multiport)
|
||||
if $limit_new_tcp_connections_per_seconds_per_source_IP \
|
||||
&& [[ ${#limit_new_tcp_connections_per_seconds_ports} -gt 0 ]]; then
|
||||
|
||||
#$ipt -A INPUT -p tcp -m conntrack --ctstate NEW -m limit --limit 60/s --limit-burst 20 -j ACCEPT
|
||||
if [[ -z "$limit_new_tcp_connections_per_seconds_rate" \
|
||||
|| ! "$limit_new_tcp_connections_per_seconds_rate" =~ ^[0-9]+$ ]]; then
|
||||
limit_new_tcp_connections_per_seconds_rate=$default_limit_new_tcp_connections_per_seconds_rate
|
||||
fi
|
||||
limit_new_tcp_connections_per_seconds_burst=$((limit_new_tcp_connections_per_seconds_rate * 2))
|
||||
|
||||
# Rate-Limit für neue SYNs auf 443 pro IP
|
||||
# Only (syn) packets above the limit are dropped here. Packets below the
|
||||
# limit are not accepted but pass on to the rules of the services, so this
|
||||
# does not open any port and does not bypass later limits.
|
||||
if can_use_hashlimit ; then
|
||||
$ipt -A INPUT -p tcp --syn \
|
||||
-m multiport --dports $limit_new_tcp_connections_per_seconds_ports \
|
||||
-m hashlimit --hashlimit-name syn_multi_v4 \
|
||||
--hashlimit 30/second --hashlimit-burst 60 \
|
||||
--hashlimit-mode srcip --hashlimit-srcmask 32 \
|
||||
-j ACCEPT
|
||||
|
||||
if $log_rejected || $log_all ; then
|
||||
if $log_rejected || $log_all ; then
|
||||
$ipt -A INPUT -p tcp --syn \
|
||||
-m multiport --dports $limit_new_tcp_connections_per_seconds_ports \
|
||||
-m hashlimit --hashlimit-name syn_multi_v4_log --hashlimit-mode srcip \
|
||||
--hashlimit-srcmask 32 \
|
||||
--hashlimit-above ${limit_new_tcp_connections_per_seconds_rate}/second \
|
||||
--hashlimit-burst $limit_new_tcp_connections_per_seconds_burst \
|
||||
-m limit --limit 2/second --limit-burst 10 \
|
||||
-j $LOG_TARGET $tag_log_prefix "$log_prefix SYN over limit (multiport):"
|
||||
fi
|
||||
|
||||
# rate-limited logging für Überschreiter
|
||||
$ipt -A INPUT -p tcp --syn \
|
||||
-m multiport --dports $limit_new_tcp_connections_per_seconds_ports \
|
||||
-m hashlimit --hashlimit-name syn_multi_v4_log \
|
||||
--hashlimit 2/second --hashlimit-burst 10 \
|
||||
--hashlimit-mode srcip --hashlimit-srcmask 32 \
|
||||
-j $LOG_TARGET $tag_log_prefix "$log_prefix SYN over limit (multiport):"
|
||||
-m hashlimit --hashlimit-name syn_multi_v4 --hashlimit-mode srcip \
|
||||
--hashlimit-srcmask 32 \
|
||||
--hashlimit-above ${limit_new_tcp_connections_per_seconds_rate}/second \
|
||||
--hashlimit-burst $limit_new_tcp_connections_per_seconds_burst \
|
||||
-j DROP
|
||||
|
||||
else
|
||||
|
||||
warn "xt_hashlimit not available; using simple global limit fallback for SYN rate limiting (multiport)."
|
||||
|
||||
$ipt -N syn-multi-limit
|
||||
$ipt -A syn-multi-limit \
|
||||
-m limit --limit ${limit_new_tcp_connections_per_seconds_rate}/second \
|
||||
--limit-burst $limit_new_tcp_connections_per_seconds_burst \
|
||||
-j RETURN
|
||||
if $log_rejected || $log_all ; then
|
||||
$ipt -A syn-multi-limit -m limit --limit 2/second --limit-burst 10 \
|
||||
-j $LOG_TARGET $tag_log_prefix "$log_prefix SYN over limit (multiport):"
|
||||
fi
|
||||
$ipt -A syn-multi-limit -j DROP
|
||||
|
||||
$ipt -A INPUT -p tcp --syn \
|
||||
-m multiport --dports $limit_new_tcp_connections_per_seconds_ports \
|
||||
-j syn-multi-limit
|
||||
fi
|
||||
else
|
||||
warn "xt_hashlimit not available; using simple global limit fallback for SYN rate limiting (multiport)."
|
||||
$ipt -A INPUT -p tcp --syn \
|
||||
-m multiport --dports $limit_new_tcp_connections_per_seconds_ports \
|
||||
-m limit --limit 30/second --limit-burst 60 \
|
||||
-j ACCEPT
|
||||
fi
|
||||
|
||||
|
||||
#$ipt -A INPUT -p tcp -m conntrack --ctstate NEW -j DROP
|
||||
|
||||
$ipt -A INPUT -p tcp --syn -m multiport --dports $limit_new_tcp_connections_per_seconds_ports -j DROP
|
||||
|
||||
|
||||
echo_done
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user