removed iptables stuff
This commit is contained in:
parent
e8554eb35a
commit
ca352553da
1 changed files with 0 additions and 57 deletions
|
|
@ -142,27 +142,6 @@ if [[ -e /etc/openvpn/server.conf ]]; then
|
||||||
echo ""
|
echo ""
|
||||||
read -p "Do you really want to remove OpenVPN? [y/n]: " -e -i n REMOVE
|
read -p "Do you really want to remove OpenVPN? [y/n]: " -e -i n REMOVE
|
||||||
if [[ "$REMOVE" = 'y' ]]; then
|
if [[ "$REMOVE" = 'y' ]]; then
|
||||||
PORT=$(grep '^port ' /etc/openvpn/server.conf | cut -d " " -f 2)
|
|
||||||
if pgrep firewalld; then
|
|
||||||
# Using both permanent and not permanent rules to avoid a firewalld reload.
|
|
||||||
firewall-cmd --zone=public --remove-port=$PORT/udp
|
|
||||||
firewall-cmd --zone=trusted --remove-source=10.8.0.0/24
|
|
||||||
firewall-cmd --permanent --zone=public --remove-port=$PORT/udp
|
|
||||||
firewall-cmd --permanent --zone=trusted --remove-source=10.8.0.0/24
|
|
||||||
fi
|
|
||||||
if iptables -L -n | grep -qE 'REJECT|DROP'; then
|
|
||||||
sed -i "/iptables -I INPUT -p udp --dport $PORT -j ACCEPT/d" $RCLOCAL
|
|
||||||
sed -i "/iptables -I FORWARD -s 10.8.0.0\/24 -j ACCEPT/d" $RCLOCAL
|
|
||||||
sed -i "/iptables -I FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT/d" $RCLOCAL
|
|
||||||
fi
|
|
||||||
sed -i '/iptables -t nat -A POSTROUTING -s 10.8.0.0\/24 -j SNAT --to /d' $RCLOCAL
|
|
||||||
if hash sestatus 2>/dev/null; then
|
|
||||||
if sestatus | grep "Current mode" | grep -qs "enforcing"; then
|
|
||||||
if [[ "$PORT" != '1194' ]]; then
|
|
||||||
semanage port -d -t openvpn_port_t -p udp $PORT
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if [[ "$OS" = 'debian' ]]; then
|
if [[ "$OS" = 'debian' ]]; then
|
||||||
apt-get remove --purge -y openvpn openvpn-blacklist
|
apt-get remove --purge -y openvpn openvpn-blacklist
|
||||||
elif [[ "$OS" = 'arch' ]]; then
|
elif [[ "$OS" = 'arch' ]]; then
|
||||||
|
|
@ -482,42 +461,6 @@ verb 3" >> /etc/openvpn/server.conf
|
||||||
fi
|
fi
|
||||||
# Avoid an unneeded reboot
|
# Avoid an unneeded reboot
|
||||||
echo 1 > /proc/sys/net/ipv4/ip_forward
|
echo 1 > /proc/sys/net/ipv4/ip_forward
|
||||||
# Set NAT for the VPN subnet
|
|
||||||
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -j SNAT --to $IP
|
|
||||||
sed -i "1 a\iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -j SNAT --to $IP" $RCLOCAL
|
|
||||||
if pgrep firewalld; then
|
|
||||||
# We don't use --add-service=openvpn because that would only work with
|
|
||||||
# the default port. Using both permanent and not permanent rules to
|
|
||||||
# avoid a firewalld reload.
|
|
||||||
if [[ "$PROTOCOL" = 'UDP' ]]; then
|
|
||||||
firewall-cmd --zone=public --add-port=$PORT/udp
|
|
||||||
firewall-cmd --permanent --zone=public --add-port=$PORT/udp
|
|
||||||
elif [[ "$PROTOCOL" = 'TCP' ]]; then
|
|
||||||
firewall-cmd --zone=public --add-port=$PORT/tcp
|
|
||||||
firewall-cmd --permanent --zone=public --add-port=$PORT/tcp
|
|
||||||
fi
|
|
||||||
firewall-cmd --zone=trusted --add-source=10.8.0.0/24
|
|
||||||
firewall-cmd --permanent --zone=trusted --add-source=10.8.0.0/24
|
|
||||||
fi
|
|
||||||
if iptables -L -n | grep -qE 'REJECT|DROP'; then
|
|
||||||
# If iptables has at least one REJECT rule, we asume this is needed.
|
|
||||||
# Not the best approach but I can't think of other and this shouldn't
|
|
||||||
# cause problems.
|
|
||||||
if [[ "$PROTOCOL" = 'UDP' ]]; then
|
|
||||||
iptables -I INPUT -p udp --dport $PORT -j ACCEPT
|
|
||||||
elif [[ "$PROTOCOL" = 'TCP' ]]; then
|
|
||||||
iptables -I INPUT -p tcp --dport $PORT -j ACCEPT
|
|
||||||
fi
|
|
||||||
iptables -I FORWARD -s 10.8.0.0/24 -j ACCEPT
|
|
||||||
iptables -I FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
|
|
||||||
if [[ "$PROTOCOL" = 'UDP' ]]; then
|
|
||||||
sed -i "1 a\iptables -I INPUT -p udp --dport $PORT -j ACCEPT" $RCLOCAL
|
|
||||||
elif [[ "$PROTOCOL" = 'TCP' ]]; then
|
|
||||||
sed -i "1 a\iptables -I INPUT -p tcp --dport $PORT -j ACCEPT" $RCLOCAL
|
|
||||||
fi
|
|
||||||
sed -i "1 a\iptables -I FORWARD -s 10.8.0.0/24 -j ACCEPT" $RCLOCAL
|
|
||||||
sed -i "1 a\iptables -I FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT" $RCLOCAL
|
|
||||||
fi
|
|
||||||
# If SELinux is enabled and a custom port was selected, we need this
|
# If SELinux is enabled and a custom port was selected, we need this
|
||||||
if hash sestatus 2>/dev/null; then
|
if hash sestatus 2>/dev/null; then
|
||||||
if sestatus | grep "Current mode" | grep -qs "enforcing"; then
|
if sestatus | grep "Current mode" | grep -qs "enforcing"; then
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue