From be22048a2b384f1a3193cfc9f5c27b0671e66842 Mon Sep 17 00:00:00 2001 From: Christopher Brickley Date: Thu, 23 Oct 2014 09:16:51 -0400 Subject: [PATCH] avoid dup iptables rules --- bin/ovpn_run | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bin/ovpn_run b/bin/ovpn_run index eb97d90..1722e98 100755 --- a/bin/ovpn_run +++ b/bin/ovpn_run @@ -19,10 +19,13 @@ fi # Setup NAT forwarding if requested if [ "$OVPN_DEFROUTE" != "0" ];then - iptables -t nat -A POSTROUTING -s $OVPN_SERVER -o eth0 -j MASQUERADE - + iptables -t nat -C POSTROUTING -s $OVPN_SERVER -o eth0 -j MASQUERADE || { + iptables -t nat -A POSTROUTING -s $OVPN_SERVER -o eth0 -j MASQUERADE + } for i in "${OVPN_ROUTES[@]}"; do - iptables -t nat -A POSTROUTING -s "$i" -o eth0 -j MASQUERADE + iptables -t nat -C POSTROUTING -s "$i" -o eth0 -j MASQUERADE || { + iptables -t nat -A POSTROUTING -s "$i" -o eth0 -j MASQUERADE + } done fi