File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -112,6 +112,21 @@ for line in $(sort -r -n -k 2 -t \' $rules); do
112112 fi
113113done
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+
115130# Switching chain policy to DROP
116131echo " $iptables -P INPUT DROP" >> $tmp
117132
You can’t perform that action at this time.
0 commit comments