Enhance spoofed packet handling: exclude loopback traffic in IP filtering

This commit is contained in:
2026-10-27 22:30:44 +01:00
parent f6660709ce
commit 57861cb8ec
3 changed files with 15 additions and 5 deletions
+7 -2
View File
@@ -814,13 +814,18 @@ echo_done
# ---
echononl "\tBlock spoofed (own ip) packets"
# Note:
# Exclude loopback - local traffic to an own address (e.g. a web application
# requesting its own domain) passes PREROUTING via 'lo' with src = dst.
#
if $log_spoofed || $log_all ; then
for _ip in ${ext_ip_arr[@]} ; do
$ipt -t mangle -A PREROUTING -s $_ip -d $_ip -j $LOG_TARGET $tag_log_prefix "$log_prefix Spoofed (own ip): "
$ipt -t mangle -A PREROUTING ! -i lo -s $_ip -d $_ip -j $LOG_TARGET $tag_log_prefix "$log_prefix Spoofed (own ip): "
done
fi
for _ip in ${ext_ip_arr[@]} ; do
$ipt -t mangle -A PREROUTING -s $_ip -d $_ip -j DROP
$ipt -t mangle -A PREROUTING ! -i lo -s $_ip -d $_ip -j DROP
done
echo_done