From aad2ec848b6596eb5330ee2b3913fee75ccd688f Mon Sep 17 00:00:00 2001 From: BornToBeRoot Date: Mon, 29 Apr 2019 03:53:38 +0200 Subject: [PATCH] Update openvpn-install.sh --- openvpn-install.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/openvpn-install.sh b/openvpn-install.sh index 782f3db..325cbf9 100755 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -856,20 +856,20 @@ verb 3" >> /etc/openvpn/server.conf if pgrep firewalld; then # Allow incoming traffic if [[ "$PORT" == '1194' ]]; then - firewall-cmd --zone=public --add-service=openvpn + firewall-cmd --zone=public --add-service=openvpn firewall-cmd --permanent --zone=public --add-service=openvpn else firewall-cmd --zone=public --add-port=$PORT/$PROTOCOL firewall-cmd --permanent --zone=public --add-port=$PORT/$PROTOCOL - fi + fi # Add trusted zone - firewall-cmd --zone=trusted --add-source=10.8.0.0/24 - firewall-cmd --permanent --zone=trusted --add-source=10.8.0.0/24 + firewall-cmd --zone=trusted --add-source=10.8.0.0/24 + firewall-cmd --permanent --zone=trusted --add-source=10.8.0.0/24 # Set NAT for the VPN subnet firewall-cmd --direct --add-rule ipv4 nat POSTROUTING 0 -s 10.8.0.0/24 ! -d 10.8.0.0/24 -j SNAT --to $IP - firewall-cmd --permanent --direct --add-rule ipv4 nat POSTROUTING 0 -s 10.8.0.0/24 ! -d 10.8.0.0/24 -j SNAT --to $IP + firewall-cmd --permanent --direct --add-rule ipv4 nat POSTROUTING 0 -s 10.8.0.0/24 ! -d 10.8.0.0/24 -j SNAT --to $IP else # Add iptables rules in two scripts mkdir /etc/iptables @@ -1147,15 +1147,15 @@ function removeOpenVPN () { # Remove firewall rules --> firewalld / iptable (systemd scripts) if pgrep firewalld; then - 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) - if [[ "$PORT" == '1194' ]]; then + if [[ "$PORT" == '1194' ]]; then firewall-cmd --zone=public --remove-service=openvpn firewall-cmd --permanent --zone=public --remove-service=openvpn else firewall-cmd --zone=public --remove-port=$PORT/$PROTOCOL firewall-cmd --permanent --zone=public --remove-port=$PORT/$PROTOCOL - fi + fi firewall-cmd --zone=trusted --remove-source=10.8.0.0/24 firewall-cmd --permanent --zone=trusted --remove-source=10.8.0.0/24