diff --git a/openvpn-install.sh b/openvpn-install.sh index bc593c0..87905ec 100644 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -80,7 +80,7 @@ if [[ -e /etc/openvpn/server.conf ]]; then echo " 4) Exit" read -p "Select an option [1-4]: " option case $option in - 1) + 1) echo "" echo "Tell me a name for the client certificate" echo "Please, use one word only, no special characters" @@ -125,7 +125,7 @@ if [[ -e /etc/openvpn/server.conf ]]; then echo "Certificate for client $CLIENT revoked" exit ;; - 3) + 3) echo "" read -p "Do you really want to remove OpenVPN? [y/n]: " -e -i n REMOVE if [[ "$REMOVE" = 'y' ]]; then @@ -195,10 +195,10 @@ else echo " 2) TCP" read -p "Protocol [1-2]: " -e -i 1 PROTOCOL case $PROTOCOL in - 1) + 1) PROTOCOL=udp ;; - 2) + 2) PROTOCOL=tcp ;; esac @@ -206,6 +206,11 @@ else echo "What port do you want OpenVPN listening to?" read -p "Port: " -e -i 1194 PORT echo "" + echo "What IP do you want OpenVPN listening to?" + read -p "Port: " -e -i 10.8.0.0 OPENVPNHOST + echo "" + read -r -p "Do you want to tunnel all traffic thru VPN? [y/N] " REDIRECT + echo "" echo "Which DNS do you want to use with the VPN?" echo " 1) Current system resolvers" echo " 2) Google" @@ -267,18 +272,25 @@ dh dh.pem auth SHA512 tls-auth ta.key 0 topology subnet -server 10.8.0.0 255.255.255.0 +server $OPENVPNHOST 255.255.255.0 ifconfig-pool-persist ipp.txt" > /etc/openvpn/server.conf - echo 'push "redirect-gateway def1 bypass-dhcp"' >> /etc/openvpn/server.conf + case "$REDIRECT" in + [yY][eE][sS]|[yY]) + echo 'push "redirect-gateway def1 bypass-dhcp"' >> /etc/openvpn/server.conf + ;; + *) + # do_something_else + ;; + esac # DNS case $DNS in - 1) + 1) # Obtain the resolvers from resolv.conf and use them for OpenVPN grep -v '#' /etc/resolv.conf | grep 'nameserver' | grep -E -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | while read line; do echo "push \"dhcp-option DNS $line\"" >> /etc/openvpn/server.conf done ;; - 2) + 2) echo 'push "dhcp-option DNS 8.8.8.8"' >> /etc/openvpn/server.conf echo 'push "dhcp-option DNS 8.8.4.4"' >> /etc/openvpn/server.conf ;; @@ -286,14 +298,14 @@ ifconfig-pool-persist ipp.txt" > /etc/openvpn/server.conf echo 'push "dhcp-option DNS 208.67.222.222"' >> /etc/openvpn/server.conf echo 'push "dhcp-option DNS 208.67.220.220"' >> /etc/openvpn/server.conf ;; - 4) + 4) echo 'push "dhcp-option DNS 129.250.35.250"' >> /etc/openvpn/server.conf echo 'push "dhcp-option DNS 129.250.35.251"' >> /etc/openvpn/server.conf ;; - 5) + 5) echo 'push "dhcp-option DNS 74.82.42.42"' >> /etc/openvpn/server.conf ;; - 6) + 6) echo 'push "dhcp-option DNS 64.6.64.6"' >> /etc/openvpn/server.conf echo 'push "dhcp-option DNS 64.6.65.6"' >> /etc/openvpn/server.conf ;;