Skip to content

Commit e498d87

Browse files
committed
Ubuntu/Debian save iptables rules
1 parent b00e1f6 commit e498d87

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

bin/v-update-firewall

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,10 @@ if [ -x "$VESTA/data/firewall/custom.sh" ]; then
126126
fi
127127

128128
# Checking fail2ban support
129-
chains=$VESTA/data/firewall/chains.conf
130-
for chain in $(cat $chains 2>/dev/null); do
129+
if [ ! -z "$FIREWALL_EXTENSION" ]; then
130+
chains=$(cat $VESTA/data/firewall/chains.conf 2>/dev/null)
131+
fi
132+
for chain in $chains; do
131133
eval $chain
132134
if [[ "$PORT" =~ ,|-|: ]] ; then
133135
port="-m multiport --dports $PORT"
@@ -146,7 +148,14 @@ if [ -e "/etc/redhat-release" ]; then
146148
/sbin/chkconfig iptables on
147149
fi
148150
else
149-
sbin/iptables-save > /etc/iptables.up.rules
151+
/sbin/iptables-save > /etc/iptables.rules
152+
preup="/etc/network/if-pre-up.d/iptables"
153+
if [ ! -e "$preup" ]; then
154+
echo '#!/bin/sh' > $preup
155+
echo "/sbin/iptables-restore < /etc/iptables.rules" >> $preup
156+
echo "exit 0" >> $preup
157+
chmod +x $preup
158+
fi
150159
fi
151160

152161

0 commit comments

Comments
 (0)