firewall-cmd service openvpn is only udp

This commit is contained in:
BornToBeRoot 2019-04-30 21:55:56 +02:00
parent 0432dfaf2c
commit 8c76c4a542

View File

@ -855,7 +855,7 @@ verb 3" >> /etc/openvpn/server.conf
# Add firewall rules --> firewalld / iptable (systemd scripts) # Add firewall rules --> firewalld / iptable (systemd scripts)
if pgrep firewalld; then if pgrep firewalld; then
# Allow incoming traffic # Allow incoming traffic
if [[ "$PORT" == '1194' ]]; then if [[ "$PORT" == '1194' ]] && [[ "$PROTOCOL" == "udp" ]]; then
firewall-cmd --zone=public --add-service=openvpn firewall-cmd --zone=public --add-service=openvpn
firewall-cmd --permanent --zone=public --add-service=openvpn firewall-cmd --permanent --zone=public --add-service=openvpn
else else
@ -1125,9 +1125,8 @@ function removeOpenVPN () {
echo "" echo ""
read -rp "Do you really want to remove OpenVPN? [y/n]: " -e -i n REMOVE read -rp "Do you really want to remove OpenVPN? [y/n]: " -e -i n REMOVE
if [[ "$REMOVE" = 'y' ]]; then if [[ "$REMOVE" = 'y' ]]; then
# Get OpenVPN port and protocol from the configuration # Get OpenVPN port from the configuration
PORT=$(grep '^port ' /etc/openvpn/server.conf | cut -d " " -f 2) PORT=$(grep '^port ' /etc/openvpn/server.conf | cut -d " " -f 2)
PROTOCOL=$(grep '^proto ' /etc/openvpn/server.conf | cut -d " " -f 2)
# Stop OpenVPN # Stop OpenVPN
if [[ "$OS" =~ (fedora|arch) ]]; then if [[ "$OS" =~ (fedora|arch) ]]; then
@ -1147,9 +1146,12 @@ function removeOpenVPN () {
# Remove firewall rules --> firewalld / iptable (systemd scripts) # Remove firewall rules --> firewalld / iptable (systemd scripts)
if pgrep firewalld; then if pgrep firewalld; then
# Get IP from firewall-cmd
IP=$(firewall-cmd --direct --get-rules ipv4 nat POSTROUTING | grep '\-s 10.8.0.0/24 '"'"'!'"'"' -d 10.8.0.0/24 -j SNAT --to ' | cut -d " " -f 10) IP=$(firewall-cmd --direct --get-rules ipv4 nat POSTROUTING | grep '\-s 10.8.0.0/24 '"'"'!'"'"' -d 10.8.0.0/24 -j SNAT --to ' | cut -d " " -f 10)
# Get OpenVPN protocol from the configuration
PROTOCOL=$(grep '^proto ' /etc/openvpn/server.conf | cut -d " " -f 2)
if [[ "$PORT" == '1194' ]]; then if [[ "$PORT" == '1194' ]] && [[ "$PROTOCOL" == "udp" ]]; then
firewall-cmd --zone=public --remove-service=openvpn firewall-cmd --zone=public --remove-service=openvpn
firewall-cmd --permanent --zone=public --remove-service=openvpn firewall-cmd --permanent --zone=public --remove-service=openvpn
else else