1
1
mirror of https://github.com/namibia/openvpn-install.git synced 2024-05-28 09:00:48 +00:00

add ufw rule to allow traffic on chosen udp port

This commit is contained in:
jtbr 2016-05-17 05:28:48 +02:00
parent e2b9f116d4
commit 4f8cad83cf

View File

@ -134,6 +134,7 @@ if [[ -e /etc/openvpn/server.conf ]]; then
if [[ "$REMOVE" = 'y' ]]; then
PORT=$(grep '^port ' /etc/openvpn/server.conf | cut -d " " -f 2)
if ufw status | grep -qw active; then
ufw delete allow $PORT/udp
sed -i '/^##OPENVPN_START/,/^##OPENVPN_END/d' /etc/ufw/before.rules
sed -i 's/^DEFAULT_FORWARD_POLICY="ACCEPT" #before ovpn: /DEFAULT_FORWARD_POLICY=/g' /etc/default/ufw
fi
@ -392,6 +393,9 @@ tls-auth tls-auth.key 0" >> /etc/openvpn/server.conf
firewall-cmd --permanent --zone=public --add-port=$PORT/udp
firewall-cmd --permanent --zone=trusted --add-source=10.8.0.0/24
fi
if ufw status | grep -qw active; then
ufw allow $PORT/udp
fi
if iptables -L | 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