From a0ff4d7cf92a08cf028a5b16c02380bebdb75e06 Mon Sep 17 00:00:00 2001 From: angristan Date: Fri, 21 Sep 2018 21:53:39 +0200 Subject: [PATCH] Improve questions for NATed servers --- openvpn-install.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/openvpn-install.sh b/openvpn-install.sh index bc0f616..58311ee 100644 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -149,8 +149,7 @@ function installOpenVPN () { echo "You can leave the default options and just press enter if you are ok with them." echo "" echo "I need to know the IPv4 address of the network interface you want OpenVPN listening to." - echo "If your server is running behind a NAT, (e.g. LowEndSpirit, Scaleway) leave the IP address as it is. (local/private IP)" - echo "Otherwise, it should be your public IPv4 address." + echo "Unless your server is behind NAT, it should be your public IPv4 address." # Detect public IPv4 address and pre-fill for the user IP=$(ip addr | grep 'inet' | grep -v inet6 | grep -vE '127\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | head -1) @@ -158,8 +157,11 @@ function installOpenVPN () { # If $IP is a private IP address, the server must be behind NAT if echo "$IP" | grep -qE '^(10\.|172\.1[6789]\.|172\.2[0-9]\.|172\.3[01]\.|192\.168)'; then echo "" - echo "This server is behind NAT. What is the public IPv4 address or hostname?" - read -rp "Public IP address / hostname: " -e PUBLICIP + echo "It seems this server is behind NAT. What is its public IPv4 address?" + echo "We need it for the clients to connect to the server." + until [[ "$PUBLICIP" =~ ^((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])$ ]];do + read -rp "Public IPv4 address: " -e PUBLICIP + done fi echo ""