@@ -64,6 +64,19 @@ tmp=$(mktemp)
6464echo " $iptables -P INPUT ACCEPT" >> $tmp
6565echo " $iptables -F INPUT" >> $tmp
6666
67+ # Enabling stateful support
68+ if [ " $conntrack " != ' no' ]; then
69+ str=" $iptables -A INPUT -m state"
70+ str=" $str --state ESTABLISHED,RELATED -j ACCEPT"
71+ echo " $str " >> $tmp
72+ fi
73+
74+ # Handling local traffic
75+ for ip in $( ls $VESTA /data/ips) ; do
76+ echo " $iptables -A INPUT -s $ip -j ACCEPT" >> $tmp
77+ done
78+ echo " $iptables -A INPUT -s 127.0.0.1 -j ACCEPT" >> $tmp
79+
6780# Pasring iptables rules
6881IFS=$' \n '
6982for line in $( sort -r -n -k 2 -t \' $rules ) ; do
@@ -100,25 +113,6 @@ for line in $(sort -r -n -k 2 -t \' $rules); do
100113 fi
101114done
102115
103- # Handling local traffic
104- for ip in $( ls $VESTA /data/ips) ; do
105- echo " $iptables -A INPUT -s $ip -j ACCEPT" >> $tmp
106- done
107- echo " $iptables -A INPUT -s 127.0.0.1 -j ACCEPT" >> $tmp
108- IFS=$' \n '
109- for p_rule in $( cat $ports ) ; do
110- eval $p_rule
111- rule=" $iptables -A INPUT -p $PROTOCOL "
112- echo " $rule --sport $PORT -j ACCEPT" >> $tmp
113- done
114-
115- # Enabling stateful support
116- if [ " $conntrack " != ' no' ]; then
117- str=" $iptables -A INPUT -p tcp -m state"
118- str=" $str --state ESTABLISHED,RELATED -j ACCEPT"
119- echo " $str " >> $tmp
120- fi
121-
122116# Switching chain policy to DROP
123117echo " $iptables -P INPUT DROP" >> $tmp
124118
0 commit comments