diff --git a/firewall/firewall-add b/firewall/firewall-add index c84b4b7..2a3a29d 100755 --- a/firewall/firewall-add +++ b/firewall/firewall-add @@ -54,12 +54,12 @@ if [[ "$NSENTER" == "true" ]] ; then iptables="nsenter -t $(docker inspect --format {{.State.Pid}} $NAME) -n -- $IPTABLES -t nat"; if [[ "$PREROUTING" == "true" ]] ; then - LINES=$($iptables --line-number -n | grep $COMMENT | awk '{print $1}'| tac) + LINES=$($iptables --line-number -n | grep $COMMENT | grep PREROUTING |awk '{print $1}'| tac) # DELETE UNECESSARY LINES FROM PREVIOUS RULES if [ -n "$LINES" ] ; then for i in $LINES; do - $iptables -D PREROUTING $i + $iptables -D $i sleep 0.1 done fi @@ -67,12 +67,12 @@ if [[ "$NSENTER" == "true" ]] ; then $iptables -I PREROUTING -d $SOURCE_IP -p $PROTOCOL --dport $SOURCE_PORT -m comment --comment "$COMMENT" -j DNAT --to $TARGET_IP:$TARGET_PORT elif [[ "$POSTROUTING" == "true" ]] ; then - LINES=$($iptables --line-number -n | grep $COMMENT | awk '{print $1}'| tac) + LINES=$($iptables --line-number -n | grep $COMMENT | grep POSTROUTING | awk '{print $1}'| tac) # DELETE UNECESSARY LINES FROM PREVIOUS RULES if [ -n "$LINES" ] ; then for i in $LINES; do - $iptables -D POSTROUTING $i + $iptables -D $i sleep 0.1 done fi