1212# Defining absolute path for iptables and modprobe
1313iptables=" /sbin/iptables"
1414modprobe=" /sbin/modprobe"
15+ sysctl=" /sbin/sysctl"
1516
1617# Includes
1718source /etc/profile.d/vesta.sh
@@ -38,11 +39,16 @@ if [ ! -e "$rules" ]; then
3839 exit
3940fi
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
4450if [ $? -ne 0 ]; then
45- stateful =' no'
51+ conntrack_ftp =' no'
4652fi
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
101107done
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