Skip to content

Commit ad75b42

Browse files
committed
Remove dns implementation and rework conntrack if condition.
1 parent 21a310b commit ad75b42

File tree

1 file changed

+1
-16
lines changed

1 file changed

+1
-16
lines changed

bin/v-update-firewall

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ echo "$iptables -P INPUT ACCEPT" >> $tmp
6464
echo "$iptables -F INPUT" >> $tmp
6565

6666
# Enabling stateful support
67-
if [ "$conntrack" != 'no' ]; then
67+
if [ "$conntrack" != 'no' ] || grep --quiet container=lxc /proc/1/environ; then
6868
str="$iptables -A INPUT -m state"
6969
str="$str --state ESTABLISHED,RELATED -j ACCEPT"
7070
echo "$str" >> $tmp
@@ -112,21 +112,6 @@ for line in $(sort -r -n -k 2 -t \' $rules); do
112112
fi
113113
done
114114

115-
# Check if is LXC
116-
if grep --quiet container=lxc /proc/1/environ; then
117-
# Get active dns servers /etc/resolv.conf
118-
DNS_SERVER=$(cat /etc/resolv.conf | grep -v '^#' | grep nameserver | awk '{print $2}')
119-
120-
# Add iptable rules for dns server
121-
for ip in $DNS_SERVER
122-
do
123-
echo "$iptables -A OUTPUT -p udp -d $ip --dport 53 -m state --state NEW,ESTABLISHED -j ACCEPT" >> $tmp
124-
echo "$iptables -A INPUT -p udp -s $ip --sport 53 -m state --state ESTABLISHED -j ACCEPT" >> $tmp
125-
echo "$iptables -A OUTPUT -p tcp -d $ip --dport 53 -m state --state NEW,ESTABLISHED -j ACCEPT" >> $tmp
126-
echo "$iptables -A INPUT -p tcp -s $ip --sport 53 -m state --state ESTABLISHED -j ACCEPT" >> $tmp
127-
done
128-
fi
129-
130115
# Switching chain policy to DROP
131116
echo "$iptables -P INPUT DROP" >> $tmp
132117

0 commit comments

Comments
 (0)