From dd0ffa2d56a6ef6a0a7bc6b2b73976f8aa216c01 Mon Sep 17 00:00:00 2001 From: gyurix Date: Mon, 16 May 2022 09:05:26 +0000 Subject: [PATCH] Modifying source or target IP addresses in case of POSTROUTING rules is applied --- firewall/firewall-add | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/firewall/firewall-add b/firewall/firewall-add index 785d3da..a015d1f 100755 --- a/firewall/firewall-add +++ b/firewall/firewall-add @@ -39,6 +39,17 @@ elif [[ "$(echo $SOURCE_IP | cut -d . -f4)" == "0" ]] ; then SOURCE_IP="$SOURCE_IP/24"; debug "source ip is $SOURCE_IP" +# Modifying source or target IP addresses if POSTROUTING rules needed to applied +elif [[ ! -z "$POSTROUTING" ]]; then + if [[ ! -z "$SOURCE_IP" ]]; then + SOURCE_IP="$(echo $SOURCE_IP | cut -d . -f1-3).0/24"; + debug "source ip is $SOURCE_IP" + fi + + if [[ ! -z "$TARGET_IP" ]]; then + TARGET_IP="$(echo $TARGET_IP | cut -d . -f1-3).0/24"; + debug "target ip is $TARGET_IP" + fi fi; if [[ -z "$TARGET_IP" ]]; then