diff --git a/vpnsetup.sh b/vpnsetup.sh index 82ab096..9e49447 100755 --- a/vpnsetup.sh +++ b/vpnsetup.sh @@ -172,10 +172,10 @@ export DEBIAN_FRONTEND=noninteractive bigecho "Trying to auto discover IP of this server..." # In case auto IP discovery fails, enter server's public IP here. -PUBLIC_IP=${VPN_PUBLIC_IP:-''} -[ -z "$PUBLIC_IP" ] && PUBLIC_IP=$(dig @resolver1.opendns.com -t A -4 myip.opendns.com +short) -check_ip "$PUBLIC_IP" || PUBLIC_IP=$(wget -t 3 -T 15 -qO- http://ipv4.icanhazip.com) -check_ip "$PUBLIC_IP" || exiterr "Cannot detect this server's public IP. Edit the script and manually enter it." +public_ip=${VPN_PUBLIC_IP:-''} +check_ip "$public_ip" || public_ip=$(dig @resolver1.opendns.com -t A -4 myip.opendns.com +short) +check_ip "$public_ip" || public_ip=$(wget -t 3 -T 15 -qO- http://ipv4.icanhazip.com) +check_ip "$public_ip" || exiterr "Cannot detect this server's public IP. Edit the script and manually enter it." bigecho "Installing packages required for the VPN..." @@ -272,7 +272,7 @@ config setup conn shared left=%defaultroute - leftid=$PUBLIC_IP + leftid=$public_ip right=%any encapsulation=yes authby=secret @@ -537,7 +537,7 @@ IPsec VPN server is now ready for use! Connect to your new VPN with these details: -Server IP: $PUBLIC_IP +Server IP: $public_ip IPsec PSK: $VPN_IPSEC_PSK Username: $VPN_USER Password: $VPN_PASSWORD diff --git a/vpnsetup_amzn.sh b/vpnsetup_amzn.sh index 2332bc5..d9c7214 100755 --- a/vpnsetup_amzn.sh +++ b/vpnsetup_amzn.sh @@ -124,10 +124,10 @@ bigecho "Installing packages required for setup..." bigecho "Trying to auto discover IP of this server..." # In case auto IP discovery fails, enter server's public IP here. -PUBLIC_IP=${VPN_PUBLIC_IP:-''} -[ -z "$PUBLIC_IP" ] && PUBLIC_IP=$(dig @resolver1.opendns.com -t A -4 myip.opendns.com +short) -check_ip "$PUBLIC_IP" || PUBLIC_IP=$(wget -t 3 -T 15 -qO- http://ipv4.icanhazip.com) -check_ip "$PUBLIC_IP" || exiterr "Cannot detect this server's public IP. Edit the script and manually enter it." +public_ip=${VPN_PUBLIC_IP:-''} +check_ip "$public_ip" || public_ip=$(dig @resolver1.opendns.com -t A -4 myip.opendns.com +short) +check_ip "$public_ip" || public_ip=$(wget -t 3 -T 15 -qO- http://ipv4.icanhazip.com) +check_ip "$public_ip" || exiterr "Cannot detect this server's public IP. Edit the script and manually enter it." bigecho "Adding the EPEL repository..." @@ -228,7 +228,7 @@ config setup conn shared left=%defaultroute - leftid=$PUBLIC_IP + leftid=$public_ip right=%any encapsulation=yes authby=secret @@ -461,7 +461,7 @@ IPsec VPN server is now ready for use! Connect to your new VPN with these details: -Server IP: $PUBLIC_IP +Server IP: $public_ip IPsec PSK: $VPN_IPSEC_PSK Username: $VPN_USER Password: $VPN_PASSWORD diff --git a/vpnsetup_centos.sh b/vpnsetup_centos.sh index e933e6f..54d458e 100755 --- a/vpnsetup_centos.sh +++ b/vpnsetup_centos.sh @@ -140,10 +140,10 @@ bigecho "Installing packages required for setup..." bigecho "Trying to auto discover IP of this server..." # In case auto IP discovery fails, enter server's public IP here. -PUBLIC_IP=${VPN_PUBLIC_IP:-''} -[ -z "$PUBLIC_IP" ] && PUBLIC_IP=$(dig @resolver1.opendns.com -t A -4 myip.opendns.com +short) -check_ip "$PUBLIC_IP" || PUBLIC_IP=$(wget -t 3 -T 15 -qO- http://ipv4.icanhazip.com) -check_ip "$PUBLIC_IP" || exiterr "Cannot detect this server's public IP. Edit the script and manually enter it." +public_ip=${VPN_PUBLIC_IP:-''} +check_ip "$public_ip" || public_ip=$(dig @resolver1.opendns.com -t A -4 myip.opendns.com +short) +check_ip "$public_ip" || public_ip=$(wget -t 3 -T 15 -qO- http://ipv4.icanhazip.com) +check_ip "$public_ip" || exiterr "Cannot detect this server's public IP. Edit the script and manually enter it." bigecho "Adding the EPEL repository..." @@ -277,7 +277,7 @@ config setup conn shared left=%defaultroute - leftid=$PUBLIC_IP + leftid=$public_ip right=%any encapsulation=yes authby=secret @@ -549,7 +549,7 @@ IPsec VPN server is now ready for use! Connect to your new VPN with these details: -Server IP: $PUBLIC_IP +Server IP: $public_ip IPsec PSK: $VPN_IPSEC_PSK Username: $VPN_USER Password: $VPN_PASSWORD