Skip to content

Commit f78a078

Browse files
committed
Merge pull request hestiacp#332 from StudioMaX/patch-1
Update v-update-firewall
2 parents 337e182 + 7d05494 commit f78a078

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

bin/v-update-firewall

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# Defining absolute path for iptables and modprobe
1313
iptables="/sbin/iptables"
1414
modprobe="/sbin/modprobe"
15+
sysctl="/sbin/sysctl"
1516

1617
# Includes
1718
source /etc/profile.d/vesta.sh
@@ -38,11 +39,16 @@ if [ ! -e "$rules" ]; then
3839
exit
3940
fi
4041

42+
$sysctl net.netfilter.nf_conntrack_max >/dev/null 2>&1
43+
if [ $? -ne 0 ]; then
44+
conntrack='no'
45+
fi
46+
4147
# Checking conntrack module avaiabilty
4248
$modprobe nf_conntrack >/dev/null 2>&1
4349
$modprobe nf_conntrack_ftp >/dev/null 2>&1
4450
if [ $? -ne 0 ]; then
45-
stateful='no'
51+
conntrack_ftp='no'
4652
fi
4753

4854
# Creating temporary file
@@ -75,7 +81,7 @@ for line in $(sort -r -n -k 2 -t \' $rules); do
7581

7682
# Checking FTP for contrack module
7783
if [ "$TYPE" = "FTP" ] || [ "$PORT" = '21' ]; then
78-
if [ "$stateful" != 'no' ]; then
84+
if [ "$conntrack_ftp" != 'no' ]; then
7985
state="-m conntrack --ctstate NEW"
8086
else
8187
port="-m multiport --dports 20,21,12000:12100"
@@ -101,7 +107,7 @@ for p_rule in $(cat $ports); do
101107
done
102108

103109
# Enabling stateful support
104-
if [ "$stateful" != 'no' ]; then
110+
if [ "$conntrack" != 'no' ]; then
105111
str="$iptables -A INPUT -p tcp -m state"
106112
str="$str --state ESTABLISHED,RELATED -j ACCEPT"
107113
echo "$str" >> $tmp

0 commit comments

Comments
 (0)