Commented IP set when them not exist

This commit is contained in:
2023-03-12 11:42:09 +00:00
parent 83e1291943
commit 2ad946f90b

View File

@@ -149,8 +149,8 @@ fi;
if [[ -z "$SOURCE_IP" ]]; then
if [[ -z "$SOURCE" ]]; then
SOURCE_IP="0.0.0.0/0";
#SOURCE_IP="0.0.0.0/0";
echo "No source IP added"
else
IDX=0
for i in $(echo $SOURCE) ; do
@@ -196,8 +196,8 @@ fi
if [[ -z "$TARGET_IP" ]]; then
if [[ -z "$TARGET" ]]; then
TARGET_IP="0.0.0.0/0";
#TARGET_IP="0.0.0.0/0";
echo "No target IP added"
else
IDX=0
for i in $(echo $TARGET) ; do
@@ -273,11 +273,11 @@ postrouting() {
if [[ ! -z "$SOURCE_IP" ]]; then
SOURCE_IP_FOR_POSTROUTING="$(echo $SOURCE_IP | cut -d . -f1-3).0/24";
debug "source ip is $SOURCE_IP_FOR_POSTROUTING"
fi
if [[ ! -z "$TARGET_IP" ]]; then
elif [[ ! -z "$TARGET_IP" ]]; then
TARGET_IP_FOR_POSTROUTING="$(echo $TARGET_IP | cut -d . -f1-3).0/24";
debug "target ip is $TARGET_IP_FOR_POSTROUTING"
fi
if [ -n "$SOURCE_IP" ] ; then
@@ -293,8 +293,8 @@ postrouting() {
done
fi
debug "$IPTABLES -I POSTROUTING -s $SOURCE_IP_FOR_POSTROUTING -p $PROTOCOL --dport $SOURCE_PORT -m comment --comment "$COMMENT" -j MASQUERADE"
$IPTABLES -w -I POSTROUTING -d $SOURCE_IP_FOR_POSTROUTING -p $PROTOCOL --dport $SOURCE_PORT -m comment --comment "$COMMENT" -j MASQUERADE
debug "$IPTABLES -I POSTROUTING -s $SOURCE_IP_FOR_POSTROUTING -p $PROTOCOL --sport $SOURCE_PORT -m comment --comment "$COMMENT" -j MASQUERADE"
$IPTABLES -w -I POSTROUTING -s $SOURCE_IP_FOR_POSTROUTING -p $PROTOCOL --sport $SOURCE_PORT -m comment --comment "$COMMENT" -j MASQUERADE
fi
if [ -n "$TARGET_IP" ] ; then