From 646d52bfadb28403c707f3efe7f8335951dc1bd6 Mon Sep 17 00:00:00 2001 From: simono41 Date: Sun, 1 Oct 2017 16:45:01 +0200 Subject: [PATCH] fix --- openvpn-install.sh | 12 ++++++++++-- openvpn.sh | 20 +++++++++++++++++--- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/openvpn-install.sh b/openvpn-install.sh index 0c7efef..e9e1d34 100755 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -ex + # Secure OpenVPN server installer for Debian, Ubuntu, CentOS and Arch Linux # https://github.com/Angristan/OpenVPN-install @@ -95,7 +97,7 @@ if [[ "$IP" = "" ]]; then IP=$(wget -qO- ipv4.icanhazip.com) fi # Get Internet network interface with default route -NIC=$(ip -4 route ls | grep default | grep -Po '(?<=dev )(\S+)') +NIC=$(ip -4 route ls | grep default -m 1 | grep -Po '(?<=dev )(\S+)') if [[ -e /etc/openvpn/server.conf ]]; then while : @@ -195,7 +197,7 @@ if [[ -e /etc/openvpn/server.conf ]]; then else # if not SUDO_USER, use /root homeDir="/root" fi - rm $homeDir*/.ovpn + rm $homeDir/*.ovpn echo "" echo "OpenVPN removed!" else @@ -836,3 +838,9 @@ verb 3" >> /etc/openvpn/client-template.txt echo "If you want to add more clients, you simply need to run this script another time!" fi exit 0; + +# internet-routing +iptables -t nat -F POSTROUTING +echo 1 > /proc/sys/net/ipv4/ip_forward +iptables -t nat -A POSTROUTING -o eth0 -s 10.8.0.0/24 -j MASQUERADE + diff --git a/openvpn.sh b/openvpn.sh index b56bef9..4505419 100755 --- a/openvpn.sh +++ b/openvpn.sh @@ -1,3 +1,17 @@ -openvpn --config ~/linux.ovpn & -sleep 10 -ip route add default dev tun0 +#!/bin/bash + +set -ex + +#openvpn --config ~/linux.ovpn & +#sleep 10 +#ip route add default dev tun0 + +echo "systemd start-script wird erzeugt!!!" +echo "Bitte OpenVPN config in die /etc/openvpn/client/client.conf kopieren!!!" +if [ -f /lib/systemd/system/openvpn-client@client.service ]; then +echo "link vorhanden!" +else +ln /lib/systemd/system/openvpn-client@.service /lib/systemd/system/openvpn-client@client.service +fi +systemctl enable openvpn-client@client.service +