From: Michael Tremer Date: Wed, 18 Aug 2021 16:27:29 +0000 (+0100) Subject: suricata: Store bypass flag in connmark and restore X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e1f2493fffa082a1ffd1f89e9990bb4af5c258c2;p=people%2Fms%2Fipfire-2.x.git suricata: Store bypass flag in connmark and restore Signed-off-by: Michael Tremer --- diff --git a/src/initscripts/system/firewall b/src/initscripts/system/firewall index baa39abe13..9fe222eab0 100644 --- a/src/initscripts/system/firewall +++ b/src/initscripts/system/firewall @@ -98,6 +98,9 @@ iptables_init() { iptables -t raw -N CONNTRACK iptables -t raw -A PREROUTING -j CONNTRACK + # Restore any connection marks + iptables -t mangle -A PREROUTING -j CONNMARK --restore-mark + # Fix for braindead ISPs iptables -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu diff --git a/src/initscripts/system/suricata b/src/initscripts/system/suricata index 2577621b8f..72d01b91da 100644 --- a/src/initscripts/system/suricata +++ b/src/initscripts/system/suricata @@ -154,10 +154,14 @@ function generate_fw_rules { done done - # Clear repeat bit, so that it does not confuse IPsec or QoS - iptables -w -A "${IPS_INPUT_CHAIN}" -j MARK --set-xmark "0x0/${REPEAT_MASK}" - iptables -w -A "${IPS_FORWARD_CHAIN}" -j MARK --set-xmark "0x0/${REPEAT_MASK}" - iptables -w -A "${IPS_OUTPUT_CHAIN}" -j MARK --set-xmark "0x0/${REPEAT_MASK}" + # Add common rules at the end of the chain + for chain in "${IPS_INPUT_CHAIN}" "${IPS_FORWARD_CHAIN}" "${IPS_OUTPUT_CHAIN}"; do + # Clear repeat bit + iptables -w -A "${chain}" -j MARK --set-xmark "0x0/${REPEAT_MASK}" + + # Store bypass bit in CONNMARK + iptables -w -A "${chain}" -m mark --mark "${BYPASS_MARK}/${BYPASS_MASK}" -j CONNMARK --save-mark + done fi }